Based on announcement that Azure Automation now supports Azure Resource Manager (source) I checked my solution for synchronizing Azure RemoteApp membership through Azure Automation. You can find the original blogpost here. The solution used both Service Management API cmdlets and Azure Resource Manager cmdlets. Based on the testing the Azure Resource Manager cmdlets did fail during the execution of the runbook. I’ve updated the runbook and everything is now working again using the new Azure Resource Manager cmdlets.
The problem was that the Azure Resource Manager cmdlets are renamed and the old cmdlets are not working anymore in Azure Automation. Execute the following steps to get everything configured:
- Download the updated runbook here: https://gallery.technet.microsoft.com/Sync-Azure-RemoteApp-4a1c397e
- Upload the AzureRM.Resources Module to your Azure Automation account. MVP Jakob Gottlieb Svendsen has described the steps in detail in the following blogpost: http://blog.coretech.dk/jgs/azure-automation-script-for-downloading-and-preparing-azurerm-modules-for-azure-automation/
- Create a 2 Automation Credentials; 1 with your Azure credentials and the second with your email environment credentials.
- Edit the runbook so both credentials will be used in the runbook. You have to change the following lines in the runbook:
$Cred = Get-AutomationPSCredential -Name 'Azure_Subscription' Add-AzureAccount -Credential $Cred Select-AzureSubscription -SubscriptionName '<< SUBCRIPTION_NAME >>'
$MailCred = "<< ENTER Azure AutomationCredential for Mail >>"
- After changing the above lines the following lines need to be changed before you can test the Runbook:
$userid = "<< ENTER USERID >>"
Send-MailMessage -To $Mail_Destination -Subject $subject -Body $Body -Port 587 -SmtpServer "<< ENTER MAILSERVER >>" -From $userid -BodyAsHtml -Credential $Cred
- The next step is to test the runbook, you will need to enter the following parameters each time you execute the runbook:
- AD_Group which will have the Azure AD Group which has the users
- RA_Collection which will have the name of the collection to which the users need to be added
- Mail_Destination which will have the email address where the reports need to be send to
- If the test is successfully you can publish the runbook
- The next step is to unlink the runbook and link it again with the above parameters.
After the execution of the runbook the users of the AD Group will be added to the Azure RemoteApp collection. The results of the runbook execution will be send to the email address. See below an example of the email which will be send: