Skip to content

MI doesn't work for environments that don't have a shell #2647

Description

@keegan-caruso

Microsoft.Identity.Web Library

Microsoft.Identity.Web.Certificate

Microsoft.Identity.Web version

latest

Web app

Not Applicable

Web API

Not Applicable

Token cache serialization

Not Applicable

Description

See here: https://github.com/AzureAD/microsoft-identity-web/blob/master/src/Microsoft.Identity.Web.Certificate/KeyVaultCertificateLoader.cs#L49-L53

Azure.Identity will fault if it cannot open a shell, distroless containers will not have a shell so they are guaranteed to fault.

There are options here: https://learn.microsoft.com/en-us/dotnet/api/azure.identity.defaultazurecredentialoptions?view=azure-dotnet

That allow excluding flows from the authentication chain.

The ability to supply my own or modify the options should work.

Reproduction steps

Use MI on a container build from a distroless image.

Error message

AzureCliCredential authentication failed: An error occurred trying to start process '/bin/sh' with working directory '/bin/'. No such file or directory

Id Web logs

No response

Relevant code snippets

NA

Regression

No response

Expected behavior

Able to use MI in distroless containers.

Activity

  1. jmprieur commented on Jan 22, 2024

    @jmprieur
    Collaborator

    You need to set the environment variable AZURE_EXCLUDE_AZURE_CLI_CREDENTIAL to true

    This will prevent the DefaultAzureCredential from using the Azure CLI credential provider. You can also use other environment variables to exclude other credential types, such as AZURE_EXCLUDE_INTERACTIVE_BROWSER_CREDENTIAL, or VS, VS Code, etc ..

  2. joerattazzi-microsoft commented on Jan 23, 2024

    @joerattazzi-microsoft

    Thanks for the response, Jean-Marc Prieur (@jmprieur) .

    I've tried setting that environment variable in our helm chart. I can see this set on the environment variables list, but same failure occurs:

     - name: AZURE_EXCLUDE_AZURE_CLI_CREDENTIAL
       value: 'true'
    

    Can you confirm this is the right Environment Variable to set, please? Thanks!

  3. joerattazzi-microsoft commented on Feb 28, 2024

    @joerattazzi-microsoft

    Jean-Marc Prieur (@jmprieur) - any chance you can weigh in on this?

  4. joerattazzi-microsoft commented on Mar 20, 2024

    @joerattazzi-microsoft
  5. jmprieur commented on Mar 20, 2024

    @jmprieur
    Collaborator

    I think this was fixed in the latest version.
    Do you mind to check?

  6. jmprieur commented on Apr 11, 2024

    @jmprieur
    Collaborator

    Keegan (@keegan-caruso). I believe this is done?

  7. keegan-caruso commented on Apr 11, 2024

    @keegan-caruso
    ContributorAuthor

    Working through previews with a partner. Not on main yet.

  8. added this to the 2.18.2 milestone on May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions