Feature: Add collision-resistant randomness to container image tags
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
Research direction
Start in cli/azd/pkg/project/container_helper.go at DefaultImageTag() and inspect nearby tests or test helpers for ContainerHelper and clock behavior. Done means default tags retain the timestamp while adding collision-resistant randomness, and relevant tests verify the format and distinct tags for deployments in the same second.
Written by the indexing model from the issue text.
Description
Is your feature request related to a problem?
When azd deploy runs for container-based services, the default image tag is generated from time.Now().Unix() (seconds since epoch). If two deployments happen within the same second (e.g. parallel CI pipelines, scripted multi-environment rollouts, or retry logic that re-triggers quickly), they produce identical tags. This means the second push silently overwrites the first image in the registry, and any service still referencing that tag may get unexpected content.
Describe the solution you'd like
Add a short random suffix to DefaultImageTag() so that tags are collision-resistant by construction. For example, changing from:
func (ch *ContainerHelper) DefaultImageTag() string {
return fmt.Sprintf("azd-deploy-%d", ch.clock.Now().Unix())
}
to something like:
func (ch *ContainerHelper) DefaultImageTag() string {
buf := make([]byte, 6)
_, _ = rand.Read(buf)
return fmt.Sprintf("azd-deploy-%d-%x", ch.clock.Now().Unix(), buf)
}
This produces tags like azd-deploy-1752883200-a3f1b2c4d5e6 that are unique even under same-second concurrency, while remaining human-readable and sortable by timestamp.
Describe alternatives you considered
- Project-level hook scripts that generate custom tags and store them in azd env vars before the deploy lifecycle runs. This works but forces every project to reimplement the same logic and adds maintenance burden outside of azd.
- Using git commit SHA as the tag. This is collision-resistant but loses the deployment-time ordering that
azd-deploy-{timestamp}provides, and doesn't work for dirty working trees.
Additional context
The current DefaultImageTag() lives in cli/azd/pkg/project/container_helper.go. The change is minimal (one function, one import) and backward-compatible since nothing depends on the exact tag format.
- Dominant language
- Go
- Stars
- 569
- Forks
- 365
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 132
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Azure/azure-dev
-
area/extensions
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
area/ux bug customer-reported ext-agents
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
area/docs engineering item ext-agents test automation
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
enhancement ext-agents
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
kind/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/kueue#15947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100