Today I am going to show you how to connect to Azure with the PowerShell Module. There are a few things that you should have in place before trying to connect. You will need to have an Azure Subscription and I recommend setting up Azure AD. I am not going to cover how to get Azure AD setup in this series, there are many blog post out there already on how to setup Azure AD Connect and ADFS.

What Credential should you use to connect to Azure, my recommendation is that you use an organization account that you have granted access to your Azure subscription. You have the option to use an Azure AD account also but if you have signed up to azure with a personal outlook.com or gmail address you will not be able to authenticate to Azure with that account using the scripts below.  You will get this error

Add-AzureAccount : -Credential parameter can only be used with Organization ID

credentials.

If you are running the Azure PowerShell module from your desktop you can use the following 3 lines to get connected to Azure.

If you are running the Azure PowerShell module from Azure Automation you can use this workflow as a template.

To use the above workflow you will need to create an credential asset in Azure Automation, I will cover this more in one of the Azure Automation blog post.

Deploying Azure Resources with Azure Automation Blog Series

I’ve decided to produce a single list of community based runbooks I have found useful. I will update this post as I find more.

Start Azure Automation Child Runbook

https://gallery.technet.microsoft.com/scriptcenter/Start-Azure-Automation-1ac858a9

Send Email from Azure Automation from a Visual Studio Online Service Hook

https://gallery.technet.microsoft.com/scriptcenter/Send-Email-from-Azure-e7b49e16

New Service Request from Template

https://gallery.technet.microsoft.com/scriptcenter/New-Service-Request-from-4c4a3aba

 

While troubleshooting a runbook in SMA, I found a reserved word that to my knowledge is not documented anywhere currently.

You cannot use $class as a variable in PowerShell workflow or SMA unless in an inlinescript block

This was the error I ran into:

The following errors were encountered while processing the workflow tree: ‘DynamicActivity’: The private implementation of activity ‘1: DynamicActivity’ has the following validation error: Compiler error(s) encountered processing expression “class”. Expression expected.
Continue reading