How to create Azure App Service using Azure CLI and Azure Power shell Scripts
How to create Azure App Service using Azure CLI and Azure Power shell Scripts
1. Azure CLI
Input:
C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.9>az login
Output:
Note, we have launched a browser for you to login. For old experience with device code, use "az login --use-device-code"
You have logged in. Now let us find all the subscriptions to which you have access...
[
{
"cloudName": "AzureCloud",
"id": "7dfjkh0-2dfs9a-42da-fsdf0a-fbfsdfcc6",
"isDefault": true,
"name": "Free Trial",
"state": "Enabled",
"tenantId": "2sjdhfe1a-2d32-4jsdhf7-8cde-dbjsd64",
"user": {
"name": "viren****@gmail.com",
"type": "user"
}
}
]
Input:
C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.9>az group create --location centralindia --name az-learning-rg
Output:
{
"id": "/subscriptions/7dfjkh0-2dfs9a-42da-fsdf0a-fbfsdfcc6/resourceGroups/az-learning-rg",
"location": "centralindia",
"managedBy": null,
"name": "az-learning-rg",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}
Input:
C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.9>az appservice plan create --resource-group az-learning-rg --name azappserviceplan --sku FREE --location eastus
Output:
{
"freeOfferExpirationTime": null,
"geoRegion": "East US",
"hostingEnvironmentProfile": null,
"hyperV": false,
"id": "/subscriptions/7dfjkh0-2dfs9a-42da-fsdf0a-fbfsdfcc6/resourceGroups/az-learning-rg/providers/Microsoft.Web/serverfarms/azappserviceplan",
"isSpot": false,
"isXenon": false,
"kind": "app",
"location": "East US",
"maximumElasticWorkerCount": 1,
"maximumNumberOfWorkers": 1,
"name": "azappserviceplan",
"numberOfSites": 0,
"perSiteScaling": false,
"provisioningState": "Succeeded",
"reserved": false,
"resourceGroup": "az-learning-rg",
"sku": {
"capabilities": null,
"capacity": 0,
"family": "F",
"locations": null,
"name": "F1",
"size": "F1",
"skuCapacity": null,
"tier": "Free"
},
"spotExpirationTime": null,
"status": "Ready",
"subscription": "7dfjkh0-2dfs9a-42da-fsdf0a-fbfsdfcc6",
"tags": null,
"targetWorkerCount": 0,
"targetWorkerSizeId": 0,
"type": "Microsoft.Web/serverfarms",
"workerTierName": null
}
Input:
C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.9>az webapp create --resource-group az-learning-rg --plan azappserviceplan --name az-mywebapp
Output:
{
"availabilityState": "Normal",
"clientAffinityEnabled": true,
"clientCertEnabled": false,
"clientCertExclusionPaths": null,
"cloningInfo": null,
"containerSize": 0,
"dailyMemoryTimeQuota": 0,
"defaultHostName": "az-mywebapp.azurewebsites.net",
"enabled": true,
"enabledHostNames": [
"az-mywebapp.azurewebsites.net",
"az-mywebapp.scm.azurewebsites.net"
],
"ftpPublishingUrl": "ftp://waws-prod-blu-143.ftp.azurewebsites.windows.net/site/wwwroot",
"geoDistributions": null,
"hostNameSslStates": [
{
"hostType": "Standard",
"ipBasedSslResult": null,
"ipBasedSslState": "NotConfigured",
"name": "az-mywebapp.azurewebsites.net",
"sslState": "Disabled",
"thumbprint": null,
"toUpdate": null,
"toUpdateIpBasedSsl": null,
"virtualIp": null
},
{
"hostType": "Repository",
"ipBasedSslResult": null,
"ipBasedSslState": "NotConfigured",
"name": "az-mywebapp.scm.azurewebsites.net",
"sslState": "Disabled",
"thumbprint": null,
"toUpdate": null,
"toUpdateIpBasedSsl": null,
"virtualIp": null
}
],
"hostNames": [
"az-mywebapp.azurewebsites.net"
],
"hostNamesDisabled": false,
"hostingEnvironmentProfile": null,
"httpsOnly": false,
"hyperV": false,
"id": "/subscriptions/7dfjkh0-2dfs9a-42da-fsdf0a-fbfsdfcc6/resourceGroups/az-learning-rg/providers/Microsoft.Web/sites/az-mywebapp",
"identity": null,
"inProgressOperationId": null,
"isDefaultContainer": null,
"isXenon": false,
"kind": "app",
"lastModifiedTimeUtc": "2019-10-03T04:10:41.270000",
"location": "East US",
"maxNumberOfWorkers": null,
"name": "az-mywebapp",
"outboundIpAddresses": "40.71.11.133,23.101.132.11,40.114.52.253,137.135.64.181,40.114.50.7",
"possibleOutboundIpAddresses": "40.71.11.133,23.101.132.11,40.114.52.253,137.135.64.181,40.114.50.7,40.114.15.207,137.135.71.113,40.114.53.155",
"redundancyMode": "None",
"repositorySiteName": "az-mywebapp",
"reserved": false,
"resourceGroup": "az-learning-rg",
"scmSiteAlsoStopped": false,
"serverFarmId": "/subscriptions/7dfjkh0-2ddfsfa-42da-fdffda-fbfsdfcc6/resourceGroups/az-learning-rg/providers/Microsoft.Web/serverfarms/azappserviceplan",
"siteConfig": null,
"slotSwapStatus": null,
"state": "Running",
"suspendedTill": null,
"tags": null,
"targetSwapSlot": null,
"trafficManagerHostNames": null,
"type": "Microsoft.Web/sites",
"usageState": "Normal"
}
You can check Web App to login Azure Portal:
2. Azure Power Shell
Input:
PS Azure:\> New-AzResourceGroup -Name az-learning-rg -Location eastus
Output:
ResourceGroupName : az-learning-rg
Location : eastus
ProvisioningState : Succeeded
ResourceId : /subscriptions/7dfjkh0-2dfs9a-42da-fsdf0a-fbfsdfcc6/resourceGroups/az-learning-rg
Input:
Azure:/
PS Azure:\> New-AzAppServicePlan -Name azappserviceplan-ps -Location eastus -ResourceGroupName az-learning-rg -Tier Free
Output:
Name State ResourceGroup EnabledHostNames Location
---- ----- ---------------- --------------------- --------
azappserviceplan-ps az-learning-rg East US
Input:
PS Azure:\> New-AzWebApp -Name az-webapp-ps -Location eastus -AppServicePlan azappserviceplan-ps -ResourceGroupName az-learning-rg
Output:
Name State ResourceGroup EnabledHostNames Location
---- ----- ---------------- --------------------- --------
az-webapp-ps Running az-learning-rg {az-webapp-ps.azurewebsites.net, az-webapp-ps.scm…} eastus
You can check Web App to login Azure Portal:
I hope, this will help you with automation.
Thank You