Create an Azure App Service Web App using PowerShell

There are numerous place to find this same example, but while I am ramping up my Azure PowerShell #Azure #AzurePowerShell #PowerShell skills, I though I’d go ahead and document it up so I have all this information in a single place for future reference.  While I am at it, I might as well share it on my blog here.

Here are the Azure PowerShell cmdlets required to create an Azure App Service Web App:

  • Login-AzureRmAccount
  • Set-AzureRmContext
  • New-AzureRmAppServicePlan
  • New-AzureRmWebApp
  • Get-AzureRmWebApp

Find the complete cmdlets and parameter values below.

Login-AzureRmAccount

Executing that cmdlet opens a challenge/response window, enter your credentials and the result is similar to that shown in Figure 1.

image

Figure 1, how to login into Azure using Azure PowerShell

Next, execute the Set-AzureRmContext cmdlet.

Set-AzureRmContext -SubscriptionId “25ec5bae-####-####-####-############”

Set the subscription Id to the subscription into which you want to create the Azure App Service Web App, the results is similar to that in Figure 2.

image

Figure 2, how to set the Azure subscription using Azure PowerShell

Next, create the App Service Plan (ASP), which I discuss here using the New-AzureRmAppServicePlan cmdlet.

New-AzureRmAppServicePlan -Name STICKYSLOT-ASP -Location “West Europe” -ResourceGroupName STICKYSLOT-RG -Tier Free

A short description of the parameters are below:

  • -Name, the name of the App Service Plan (cannot be changed once created, default = Dafault1)
  • -Location, where, which region do you want to create the ASP and Azure App Service Web App into
  • -ResourceGroupName, I assume you already have a resource group name, I describe some about that here and here.
  • -Tier, Free, Shared, Basic, Standard or Premium

The output, when successful is similar to that show in Figure 3.

image

Figure 3, how to set create an App Service Plan (ASP) using Azure PowerShell

Finally, execute the New-AzureRmWebApp to create the Azure App Service Web App and then the Get-AzureRmWebApp to view the details.

New-AzureRmWebApp -Name stickyslot -AppServicePlan STICKYSLOT-ASP -ResourceGroupName STICKYSLOT-RG -Location “West Europe”
Get-AzureRmWebApp -ResourceGroupName “STICKYSLOT-RG” -Name “stickyslot”

The parameters used in the example, for the New-AzureRmWebApp are:

  • -Name, the name of the Azure App Service Web App
  • -AppServicePlan, the name of the ASP created in Figure 3 via the New-AzureRmAppServicePlan
  • -ResourceGroupName, I assume you already have a resource group name, I describe some about that here and here.
  • -Location, where, which region do you want to create the ASP and Azure App Service Web App into

The same details of the parameters of the Get-AzureRmWebApp are in the above bullet list.  The output if both of those cmdlet are similar to that shown in Figure 4.

image

Figure 4, how to set create an Azure App Service Web App and view the details using Azure PowerShell

You can also create the Azure App Service Web App in the portal, however, the features created using Azure PowerShell are also visible in the portal, as shown in Figure 5.

image

Figure 5, view Azure features create by Azure PowerShell in the portal