I am a big fan of deploying Azure resources using an imperative approach.
In this example I wanted to create an App Service that used Azure Active Directory, without having to add any code, e.g. Startup.cs
.
I will use both Azure PowerShell and Azure CLI.
This raises a good question, why mix Azure PowerShell and Azure CLI?
I am using Azure CLI for it’s idempotency and PowerShell for it’s programming model, or in simpler terms, Azure CLI just does some things better easier than Azure PowerShell and vice versa.
To get started, I created two PowerShell scripts, Authenticate.ps1
, to authenticate Azure PowerShell and Azure CLI, and another, Deploy.ps1
, to create all the resources in Azure.
Authenticate.ps1
This Authenticate.ps1
script authenticates the user to Azure using the PowerShell cmdlet Connect-AzAccount
and the CLI command az login
.
The script in file format can be found at https://github.com/mattruma/MJR052/blob/master/Authenticate.ps1.
Deploy.ps1
This Deploy.ps1
script creates the following Azure resources:
- Resource Group
- Application Service Plan
- Application Service
- Application Insights
- App Registration and Service Principal
The script, in a file format, can be found at https://github.com/mattruma/MJR052/blob/master/Deploy.ps1.
Another great exercise in imperative infrastructure deployment!
Discover more from Matt Ruma
Subscribe to get the latest posts sent to your email.