'az container create' does not support --tags
Environment summary
MSI / 2.0.28 / Windows 1803.17107 / PowerShell
Feature request - update az container create to allow specifying tags upon creation
The REST API docs https://docs.microsoft.com/en-us/rest/api/container-instances/containergroups/createorupdate show that container groups themselves do support tags on PUT
Tags are commonly used by organizations for tracking metadata, such as internal billing info, which application a resource belongs to, etc. It would be great to be able to use tags with ACI on creation. Currently, users will have to drop down & use ARM templates or do a follow-up az resource tag operation
Any updates on this? az resource tag doesn't work either.
That bug was opened over a year ago too. https://github.com/Azure/azure-cli/issues/8545
any news?
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @dkkapur.
this is pretty problematic.. we are using the tags to target a specific instance that is created with terraform. we update the ACI config from azure devops with the cli but this wipes the tags clean. changes in the tags actually forces terraform to recreate the instance. below is how it sortoff works, but it is quite some ceremony for restarting a container with an adjusted env var. notice the sleep command and the no-wait.
- when omitting the no-wait. the command waits for the container to be started (which also means it's pulled) which takes way to long keeping our build agent occupied.
- when omitting the sleep command the tags command doesn't have any effect (probably because az container create resets them afterwards).
the tags command exits with an error message but the tags are being set.
$configuration = az resource list --tag role=configuration | ConvertFrom-Json | Where-Object type -EQ "Microsoft.ContainerInstance/containerGroups"
if($configuration.Count -gt 0){
$container = az container show --resource-group $configuration[0].resourceGroup --name $configuration[0].name | ConvertFrom-Json
Write-Host "Starting container"
az container create `
--no-wait `
--resource-group $container.resourceGroup `
--name $configuration[0].name `
--registry-login-server $env:DOCKER_SERVER `
--registry-username $env:DOCKER_USERNAME `
--registry-password $env:DOCKER_PASSWORD `
--image $image `
--os-type Linux `
--network-profile $container.networkProfile.id `
--restart-policy $container.restartPolicy `
--environment-variables VARIABLE_1=$var1`
Write-Host "force wait"
$wait = New-TimeSpan -Seconds 5
Start-Sleep -Seconds $wait.Seconds
Write-Host "resetting tags"
az resource tag --ids $configuration[0].id --tags role=configuration
}
how to set tags while creating with az container create?
how to set tags while creating with az container create?
You can't via CLI, that's why this issue is opened :)
Any news on the subject?
If anyone comes across this, it az resource tag does seem to work now:
az resource tag --tags vmlist=vm1 --ids /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}
# or
az resource tag --tags vmlist=vm1 --resource-group MyResourceGroup --name containerGroupName --resource-type "Microsoft.ContainerInstance/containerGroups"
Using az resource tag --tags will work for subscriptions where tagging is not enforced with Azure Policy. This option needs to be added for such scenario where customers are enforcing tagging with Azure Policy which will block the creation of the container instance in the first place.
Any update on this?
Any updates? This is a must-have for organisations enforcing tag policies on resource creation.
Any update on this?
Bumping this. Any update here?
any update?