azure-active-directoryazure-managed-identityazure-identitydefaultazurecredential

Using ManagedIdentity not service principle identity its custom user identity locally debug with c#?


I have create User identity from azure not Service principle.

process is manually I created new identity through portal add new user identity.

var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions { ManagedIdentityClientId = "Azureuseridentity"});

var blobClient = new BlobClient(new Uri("https://my.blob.core.windows.net/my-container"), credential);

in local when I using this code its giving me 401.

for SPN identity we can use Tanat client and token and can work in local environment for SPN identity>

but for custom user identity its not working. I refer this Link https://github.com/MicrosoftDocs/azure-docs/issues/90776 and they say "Managed Identity Cannot be used for local development."

any idea on this


Solution

  • Managed Identities can only be used when running your services in Azure, and DefaultAzureCredential will be able to pick up the assigned identity as expected.

    You can create an App registration (service principal) for local development and use that credential instead.