Skip to content

Instantly share code, notes, and snippets.

@ErikHen
Created March 4, 2020 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErikHen/97cd90965fc18eb7adf23fd58842b0b6 to your computer and use it in GitHub Desktop.
Save ErikHen/97cd90965fc18eb7adf23fd58842b0b6 to your computer and use it in GitHub Desktop.
$webappname = "myepienvironment" # Application name (lowercase alphanumeric only)
$subscriptionname = "My subscription name"
$resourcegroupname ="$webappname-ResourceGroup"
$location="West Europe"
$sqladminlogin = "SaUser"
$sqlpassword = "YourSecretAdminPassword1"
$startip = "111.112.113.114"
$endip = "111.112.113.114"
$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 0.0.0.0 --end-ip-address 0.0.0.0
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: $webappname.azurewebsites.net"
Write-Host "SQL server address: $sqlserverName.database.windows.net"
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