Managed Identities
Managed Identities negates the need to use passwords - or their equivalents - to connect to resources.
Resources can be created with System or User assigned identities and these identies can be given access to other resources.
For example
- App Service called app-dev-hello can be created with a System assigned identity. It now has an identity of
app-dev-hello
. - A storage account called st-dev-hello-data can be created and the identity of
app-dev-hello
can be given permissions to access it.
The code - that would run on the app service example above - for doing this is very straight forward:
var Uri = "https://" + storageAccountName + ".blob.core.windows.net/" + containerName;
BlobContainerClient containerClient = new BlobContainerClient(new Uri(Uri), new ManagedIdentityCredential());