How to create a new deployment slot with tags

Clay Casper 176 Reputation points
2023-11-15T21:40:11.5266667+00:00

I have a policy in my tenant requiring all resources to have 3 tags. I went to create a new deployment slot for my app service, but it failed because there were no tags. I don't want to clone a deployment slot, but that would probably work. Azure Portal doesn't give the option for adding tags when creating a new slot. Is there a different way where I can create a new slot (without cloning) and fulfill the policy requirements of having the tags on the resource? I also don't want to disable my policy for any amount of time.

Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
1,014 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,936 questions
0 comments No comments
{count} votes

Accepted answer
  1. AirGordon 7,150 Reputation points
    2023-11-15T22:08:58.29+00:00

    You can use Azure PowerShell and specify tags at the point of creation.

    $tags= @{ Owner = "me"; CostCentre= "Blah"; OtherTag= "Maui"}
    
    New-AzWebAppSlot -ResourceGroupName Default-Web-WestUS -Name "ContosoSite" -AppServicePlan "ContosoServicePlan" -Slot "Slot001" -Tag $tags
    

    ref: https://learn.microsoft.com/en-us/powershell/module/az.websites/new-azwebappslot?view=azps-10.4.1


    It's kinda strange that the Azure CLI doesn't provide this, but it provides the ability to inherit configuration from another slot. https://learn.microsoft.com/en-us/cli/azure/webapp/deployment/slot?view=azure-cli-latest#az-webapp-deployment-slot-create

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.