Create a Simple Azure Web App with PowerShell

Hello, this post will show you the steps to create a free, very simple web app in the Microsoft Azure platform using PowerShell.

You will need an existing subscription or sign up for a new one to follow this post. The app service plan selected is the free tier so you will not be charged / count against your Azure credits.

Visio diagram of azure resource group, app service plan and web app

Use must have Azure PowerShell installed. You can get it from the Azure Microsoft site.

Get-Module -ListAvailable Azure


Authenticate to Azure using Azure Resource Manager:


You can list your subscriptions with the following command (the command on the second line will output just the subscription names):

Get-AzureRmSubscription | Select-Object SubscriptionName

Select the subscription you want to use:

Select-AzureRmSubscription -SubscriptionName 'Your subscription name'

Create a Resource Group:

New-AzureRmResourceGroup -Name 'simple-web-app-rg' -Location 'Uk South' -Tag @{Project='Simple Web App'; 'Create By'='Me'}

Tags are a great way to manage resources and are created in PowerShell using a hashtable.

Create an App Service Plan:

New-AzureRmAppServicePlan -Name 'simple-web-app-asp' -ResourceGroupName 'simple-web-app-rg' -Location 'UK South' -Tier Free -NumberofWorkers 1 -WorkerSize Small

Create a Web App:

New-AzureRmWebApp -Name 'simple-web-app134' -ResourceGroupName 'simple-web-app-rg' -Location 'UK South' -AppServicePlan 'simple-web-app-asp'

Note: The web app name must be globally unique. Creating the web app will create the URL:

If your deployment fails, check for the error message: New-AzureRmWebApp : Website with given name simple-web-app134 already exists.

Change the name of the web app or add a random number onto the end.

That’s it. You should now be able to browse to the default template by entering the URL:

Browsing to the newly created site in google chrome

To delete all of the resources (warning, this will delete everything in the resource group, make sure you are targeting the correct resource group). Add the -Force switch parameter if you don’t want the confirmation prompts:

Remove-AzureRmResourceGroup -Name 'simple-web-app-rg'

This is handy when using the app service plans that cost money. I sometimes create a standard plan for trying out deployment slots, so I will use it while testing, then delete it afterwards. If I need it again, I’ll simply run the PowerShell commands again.

I’ve scripted this out and put it on github with variables if you’re interested in taking a look.

That’s it for now, cheers.

Leave a Reply