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
- Microsoft Azure Subscription (MSDN subscribers or sign up for one month free trial)
- Windows PowerShell. To Download PowerShell Click here
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 is two types 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 command for Azure account details
Get-AzureAccount
List all the associated Azure Subscription with Id, Type, Subscriptions and Tenants
Get-AzureSubscription
List all the associated Azure Subscription with all details such as SubscriptionId, SubscriptionName, Account, etc.
if there is only one subscription associate so no problem but if more than one Azure account is there so we need to set default azure account 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 with default web app will create in the “Southeast Asia” so we need to add location command when we are creating the web app.
Classic Portal
Azure Portal
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 already used
False means this name 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!