Managed Identity

Managed Identity in .NET: Stop Using Connection Strings

Benjamin Abt mail@benjamin-abt.com (BEN ABT)
Managed Identity

Benjamin Abt walks through replacing credential-bearing Azure connection strings with Managed Identity and narrow RBAC. The real work is not in the constructor: it is the trust boundary, the role assignments and revoking the old key afterwards.

Key points

  • Keep the service URI, namespace or server name in configuration and remove only the key, SAS or password.
  • Attaching an identity grants no data access; operations need a data-plane role such as Storage Blob Data Reader.
  • Contributor does not grant blob access through Entra: it can fetch account keys while Shared Key is still enabled.
  • Use a ManagedIdentityCredential with an explicit client ID in production instead of a broad DefaultAzureCredential chain.
  • Register one credential and long-lived Azure SDK clients via Microsoft.Extensions.Azure so token and transport caches stay shared.
  • Delete and revoke old keys and disable Shared Key or local auth, or Managed Identity is just an extra path.

Real-world use

  • A single App Service or Function App workload reading from Blob Storage without a stored key
  • Teams doing blue-green replacement who need a stable principal ahead of compute (user-assigned identity)
  • AKS workloads federating a Kubernetes service account with Entra Workload ID
  • Applications connecting to Azure SQL without a password using a contained user and narrow database permissions

This summary was generated by the agent from the original post on Benjamin Abt. The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message