Azure automation account Hybrid Worker - failed to connect to MSI

Charles Thivierge 4,141 Reputation points
2025-02-27T16:25:04.8+00:00

Hi,

I want to convert my PS runbook to Azure CLI and it has to run on a Hybrid Worker.

The PS login is like this
$AzureContext = (Connect-AzAccount -Identity).context

Now, with Azure CLI, i suppose it's the following...

$AzureContextcli = (az login --identity | convertfrom-json)

But i receive the following error:

ERROR: Failed to connect to MSI. Please make sure MSI is configured correctly.

Get Token request returned: <Response [401]>

But if i execute in Azure (not on the hybrid worker), it works well

On the hybrid worker, the az cli is installed (2.63.0)

Any idea ?

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,323 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.