Create Azure resources - HenrikWM/NNUG_GAB2018 GitHub Wiki

Create required Azure resources

This section will guide you through creating Azure resources needed to run the application in Azure.

Make sure you have installed the all of the other prerequisites before proceeding.

Get the Azure Powershell cmdlets

To install the module containing the cmdlets, we need to allow run the following command in an elevated PowerShell session:

# We need this to allow unrestricted scripts to run
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

# Or you can also scope this to just apply to the deploy.ps1 script
# powershell.exe -executionpolicy unrestricted -command .\test.ps1

# Get the NuGet package provider first
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force

Install-Module -Name AzureRM
Install-Module -Name Azure

If you have these modules installed then you might want to update them:

Update-Module -Name AzureRM
Update-Module -Name Azure

Run the Azure deploy-script

At the working copy root you will see a deploy folder. This folder contains the files used to create and deploy the Azure resources using Azure Resource Manager.

  • deploy.ps1: the powershell-script used to orchestrate the deploy
  • template.json: the ARM-template that describe the Azure resources needed
  • parameters.json: the ARM-template parameters needed by template.json

Let's re-use the same Powershell session from before.

  1. Navigate to the deploy.
  2. Open parameters.json in a text-editor and enter your initials in the value property of the your_initials parameter object.
    • Example: "value": "hwm"
    • Important: use LOWERCASE initials, otherwise the storage account will fail to create because it doesn't support uppercases in its name.
  3. To allow scripts to run, run the command:
Set-ExecutionPolicy RemoteSigned
  1. Now let's execute the deploy-script:
# Replace values for 'subscriptionId' and 'resourceGroupName' 
# When prompted for 'Deployment name', use: 'ARM-deploy'.
.\deploy.ps1 -subscriptionId <your subscription id> -resourceGroupName nnug-gab2018-<your initials> -resourceGroupLocation "West Europe"

The script will run for a few moments...

When complete, open the Azure portal and find the resource group nnug-gab2018-<your initials>. Verify that your resources look similar to this:

Resource group name: nnug-gab2018-<your initials>

Storage account: nnuggab2018<your initials>

Website App service: nnuggab2018<your initials>web

Application Insights (used by the Website App Service): nnuggab2018<your initials>appinsights

Functions App service: nnuggab2018<your initials>functions

App service plan: nnug-gab2018-<your initials>

If everything looks good, congratulations! You are ready to begin the assignments.

Troubleshooting

Deploy fails with 'Cancelled' status

After execuing deploy.ps1 and waiting, I get the error The resource operation completed with terminal provisioning state 'Canceled'

This usually means that some Azure resource timed-out during provisioning in the Azure Resource Manager. Just try running the same command again and it should complete successfully the second time.