Azure PowerShell Commands For Web App

In this article we will go step by step to Create, Remove, Name Reserved (or not) and run the Web App using Azure PowerShell on Microsoft Azure.

Prerequisites

You will learn
  • About PowerShell Tool
  • How to Create Web App using PowerShell
  • How to Remove Web App using PowerShell
  • Check Web App Name reserved or not
  • Run Web App using PowerShell command
Step 1: Install PowerShell on System.

Step 2: After installation, Open search box and search for Windows PowerShell,



There are two type of Windows PowerShell available:
  • Windows PowerShell – Command Line
  • Windows PowerShell – Execute the PowerShell script such as .ps file. GUI version of Windows PowerShell.
Windows PowerShell ISE version



Step 3:
Add Azure Subscription with PowerShell,

Add-AzureAccount





Enter your Azure Subscription credentials.




Few more commands for Azure account details.

Get-AzureAccount

List all the associate Azure Subscription with Id, Type, Subscriptions and Tenants,



Get-AzureSubscription

List all the associate Azure Subscriptions with all details such as SubscriptionId, SubscriptionName, Account, etc.



If there is only one subscription associate no problem but if more than one Azure account is there we need to set default azure accounts for all operations.

Select-AzureSubscription –SubscriptionId “paste-subscription-id-here”



Check for default subscription

Get-AzureSubscription -Default



Step 4: Create New Web App

New-AzureWebsite PowerShellWebApp01



There is one problem; by default web app will create in “Southeast Asia” so we need to add location command when we are creating the web app.

Classic Portal




Azure Portal



Step 5:

New-AzureWebsite PowerShellWebApp01 -Location “West US”



Remove Web App

Remove-AzureWebsite -Name WebAppName

Ex. Remove-AzureWebsite -Name PowerShellWebApp01

Check for Web Apps Name available or not run below command

Test-AzureName -Website PowerShellWebApp01



True means this name is already used



False means this name is available for creating new web apps

Open web app on browser

Show-AzureWebsite WebAppNameOnly

Ex. Show-AzureWebsite PowerShellWebApp01



Congratulations you have learned PowerShell command with Web App on Azure!
 
Read more articles on Azure: