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.

azure-powershell

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):

Select the subscription you want to use:

Create a Resource Group:

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

Create an App Service Plan:

Create a Web App:

Note: The web app name must be globally unique. Creating the web app will create the URL: http://webappname.azurewebsites.net.

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: yoursitename.azurewebsites.net.

Browsing to the newly created site in google chrome http://simple-web-app134.azurewebsites.net/

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:

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.