Skip to content

feat: supporting managed identity #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Oct 8, 2024
Merged

Conversation

hallvictoria
Copy link
Contributor

@hallvictoria hallvictoria commented May 10, 2024

In order to support authentication through Managed Identity, the way the client is created needs to change. Previously it was done through the from_connection_string methods. This changes the extension to instead create a BlobServiceClient first, and then use the BlobServiceClient to create the respective SDK type.

When using Managed Identity, the only way to create a BlobClient is through a BlobServiceClient. There are two ways to create a BlobServiceClient:

  1. Through the constructor: this is the only option when using Managed Identity
  2. Through from_connection_string: this is the only option when not using Managed Identity

Since there are two options in how we can create the BSC, we have to track if MI is being used. This is done through a flag as part of the Client object. We determine if MI is being used based on the connection string setting passed in.

When using managed identity, the connection string variable name is formatted like so:

  • Input: <CONNECTION_NAME_PREFIX>__serviceUri
  • Trigger: <CONNECTION_NAME_PREFIX>__blobServiceUri

The variable received will be <CONNECTION_NAME_PREFIX>. Therefore, we need to append the suffix to obtain the storage URI and create the client.

There are four cases:

  1. Not using managed identity: the environment variable exists as is
  2. Using managed identity for blob input: __serviceUri must be appended
  3. Using managed identity for blob trigger: __blobServiceUri must be appended
  4. None of these cases exist, so the connection variable is invalid.

@hallvictoria hallvictoria marked this pull request as ready for review May 13, 2024 18:41
@hallvictoria hallvictoria merged commit d855bd7 into dev Oct 8, 2024
28 checks passed
@hallvictoria hallvictoria deleted the hallvictoria/managed-identity branch October 8, 2024 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants