I am trying to shutdown the VM using Azure Automation Account System Managed identity option.
However I am ending up with below error.
As per the other articles it is mentioned to upgrade the module Update-ModulesInAutomationToLatestVersion but I could not update due to below error. I am not sure what is the issue in the script. Same script works with AzureRunAsConnection option without issues (
CodePudding user response:
For more information please refer the below links:-
- MICROSOFT DOCUMENT|Using a system-assigned managed identity for an Azure Automation account & Troubleshoot runbook issue.
CodePudding user response:
I have tested the above shared script in my automation account. Below are the couple of observations:
- You need to use
Connect-AzureRMAccount -Identity
cmdlet instead of 'connect-AzAccount` to connect to your subscription because the rest of the script that you have written using Azure RM cmdlets. - If we use
AzureRM
cmdlets in your run book script the job is getting suspended stating that Azure RM is going to retired and suggesting us to useAz
Module in your workflow. - You can refer to this documentation on how to migrate your PowerShell scripts automatically from
AzureRM
to AZ modules. - If you want to perform start/stop on your virtual Machines you can leverage the Azure Automation start/stop during the off hours feature.