Skip to content

Instantly share code, notes, and snippets.

Created March 4, 2020 15:39
What would you like to do?
$webappname = "myepienvironment" # Application name (lowercase alphanumeric only)
$subscriptionname = "My subscription name"
$resourcegroupname ="$webappname-ResourceGroup"
$location="West Europe"
$sqladminlogin = "SaUser"
$sqlpassword = "YourSecretAdminPassword1"
$startip = ""
$endip = ""
$storageaccountname = "$($webappname)media"
az login
# Set the subscription and location to use
az account set --subscription 00602b42-0000-0000-0000-00f0ebada090 # find subscription id: az account list
az configure --defaults location=$location
# Create resource group
az group create --name $resourcegroupname
az configure --defaults group=$resourcegroupname # Configure group as default
# Create App Service Plan ("Free" tier).
$serviceplanname = "$webappname-ServicePlan"
az appservice plan create --name $serviceplanname --sku Free
# Create web app.
az webapp create --name $webappname --plan $serviceplanname
az configure --defaults web=$webappname # Configure as default
az webapp config set --web-sockets-enabled true # Episerver needs websockets
az webapp config set --php-version Off # Php is not needed, so turn it off
# Create SQL server.
$sqlservername = "$webappname-sqlserver"
az sql server create --name $sqlservername --admin-user $sqladminlogin --admin-password $sqlpassword
az sql server firewall-rule create --server $sqlservername -n AllowAzureService --start-ip-address --end-ip-address
az sql server firewall-rule create --server $sqlservername -n MyOfficeIp --start-ip-address $startip --end-ip-address $endip
# Create storage account
az storage account create --name $storageaccountname --sku Standard_LRS
$storagekey = az storage account keys list -n $storageaccountname --query [0].value
Write-Host "====================================================================`n"
Write-Host "Site url: $"
Write-Host "SQL server address: $"
Write-Host "SQL server user: $sqladminlogin"
Write-Host "SQL server password: $sqlpassword"
Write-Host "Blob storage name: $storageaccountname"
Write-Host "Blob storage key: $storagekey"
Write-Host "`n===================================================================="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment