Search code examples
c#azureazure-cli

How to find out my plan to create a web app in Azure


I'm trying to create a webapp as suggested here. The group is created. Then, I omit the step of creating a plan, since I already have a subscription allowing me to do that (which I can confirm by creating the app from the GUI and picking which plan/subscription I want to use).

When I execute

az webapp create --resource-group my-group `
                 --name app-lication `
                 --plan "Enterprise MSDN Dev Test"

it fails, since the plan isn't recognized. I tried with different names and GUIDS (those I see when I az login, for instance etc.) but nothing seems to work out. How do I obtain the correct referece to my plans/subscriptions so I can pass it as the last parameter in the command above?


Solution

  • It's going to be more reliable to pass the Plan ResourceId than the name, this specifically caters for scenarios when the plan exists in a different resource group.

    The naming convention of your plan in the question is typical of an Azure Subscription. Ensure you do have a properly created App Service Plan to use.

    AppServicePlanID=$(az appservice plan show -n SharedAppServicePlan -g MyASPRG --query "id" --out tsv) 
    az webapp create -g MyResourceGroup -p "$AppServicePlanID" -n MyUniqueAppName
    

    https://learn.microsoft.com/en-us/cli/azure/webapp?view=azure-cli-latest#az-webapp-create-examples