Azure Fast Tip: Workaround for Azure Credentials expired errors

When utilizing PowerShell Workflows and even in common scripts the error Your Azure Credentials haven’t been arrange or have expired, please run Join-AzAccount to arrange your Azure credentials could also be displayed.

Azure Credentials

A workaround for this problem is to avoid wasting the Azure context in a JSON file on the Azure Automation employee node utilizing the next cmdlet.

Save-AzContext -path ((Get-Location).Path + "file.json") -Power

When required in your code that you must refresh the authentication, simply use this cmdlet:

$tmpContext = Import-AzContext -Path ((Get-Location).path + "file.json")

In case you are utilizing PowerShell Workflows, the next code can be utilized the place you add the credential for each multithread occasion. Should you use features that use Azure cmdlets, you could use the Import-AzContext throughout the perform as a substitute.

$RGs = Get-AzResourceGroup
ForEach -Parallel -ThrottleLimit 6 ($rg in $RGs)
$tmpContext = Import-AzContext -Path ((Get-Location).path + "file.json")
<Code>


Put up Views:
3



report this ad



Read Next


About the Author

Leave a Reply

Your email address will not be published. Required fields are marked *