Search code examples
azureazure-pipelinesazure-blob-storageazure-cli

When I am running a deployment command on my pipeline us it fails saying MSI is not configured properly


I am deploying a static react web app into azure static website (blob storage) using the command

While doing so I am doing it through Azure CLI (Inline command).

az storage blob upload-batch -s ./ -d '$web' \
--account-name <storage_acct_name> \
--account-key <storage_acct_key>

This command gives me an error

2022-11-17T08:27:29.5243851Z ERROR: Failed to connect to MSI. Please make sure MSI is configured correctly.
2022-11-17T08:27:29.5244667Z Get Token request returned http error: 400, reason: Bad Request
2022-11-17T08:27:29.5274714Z ##[error]Error Code: [1]
2022-11-17T08:27:29.5283948Z ##[error]Error: Azure login failed using Managed Service Identity
2022-11-17T08:27:29.5285668Z ##[error]Script failed with error: ERROR: Failed to connect to MSI. Please make sure MSI is configured correctly.

What could be possible solution to get over this issue.


Solution

  • I tried in my environment and successfully deployed static web app in $Web.

    Before running the command make sure you have logged in with current credentials:

    az login --tenant xxxx-xxxxxxxxxxxxxx-xxxxx”
    

    Command:

     az storage blob upload-batch -d '$web' -s < path > --account-name <account name > --account-key "<account key>
    

    Console:

    enter image description here

    Portal:

    enter image description here

    Reference:

    1. azure - Configuration of Managed Service Identity(MSI) - Stack Overflow for pipeline problems.
    2. Getting token from Cloud Shell intermittently fails with 400 Client Error: Bad Request · Issue #11749 · Azure/azure-cli · GitHub