Authenticate dockerized azure fuction with MSI

Obaid UrRehman 166 Reputation points
2022-04-20T20:36:27.03+00:00

I have an azure function and using docker to build image and then push docker to azurecr. The azure function contains this code:

 run = Run.get_context()  
 ws = Workspace.from_config('config.json',auth=MsiAuthentication()) if not hasattr(run, 'experiment') else run.experiment.workspace  

This works when I test the function locally using func start

but when I build docker image for the azure function and run the docker, it gives following error:

Message: Failed to connect to MSI. Please make sure MSI is configured correctly.  
      Get Token request returned http error: 400, reason: Bad Request  
        InnerException None  
        ErrorResponse   
      {  
          "error": {  
              "message": "Failed to connect to MSI. Please make sure MSI is configured correctly.\nGet Token request returned http error: 400, reason: Bad Request"  
          }  
      }  

The identity configuration for azure function has the required roles:
194784-role1.png

Or, is there any other authentication method that I should use?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,630 questions
0 comments No comments
{count} votes

Accepted answer
  1. MughundhanRaveendran-MSFT 12,451 Reputation points
    2022-04-29T15:14:30.157+00:00

    @Obaid UrRehman ,

    Thanks for reaching out to Q&A.

    The system assigned MSI is properly configured in the portal. However, it appears that there might be a problem with the docker file. I would suggest you to take a look at these blessed images for reference. If that doesnt help, please share the docker file here so can check if there are any issues with it.


0 additional answers

Sort by: Most helpful