Skip to content

Support Azure managed identities - #736

Merged
elrayle merged 3 commits into
clearlydefined:masterfrom
dangoor:dangoor/managed-identity
Mar 19, 2026
Merged

Support Azure managed identities#736
elrayle merged 3 commits into
clearlydefined:masterfrom
dangoor:dangoor/managed-identity

Conversation

@dangoor

@dangoor dangoor commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Prior to this change, the connection string would override the fall through to default Azure client authentication. We want to preserve the existing behavior while allowing the use of an Azure managed identity, so we add new environment variables to explicitly state we want to use a managed identity.

Prior to this change, the connection string would override the fall through to default Azure client authentication. We want to preserve the existing behavior while allowing the use of an Azure managed identity, so we add new environment variables to explicitly state we want to use a managed identity.
const { account, spnAuth, isSpnAuth, useManagedIdentity } = options
const useManagedIdentityEnabled = useManagedIdentity === true || useManagedIdentity === 'true'

if (useManagedIdentityEnabled) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to understand whether this change is truly needed. The current behaviour seems to be that if one doesn't specify spnAuth nor connectionString config values, the control flow would reach the existing block that uses DefaultAzureCredential.

If my understanding is correct, there's no need to add another config value like useManagedIdentityEnabled. It's sufficient for deployments that wish to use managed identity to set values for the spnAuth and connectionString to none/empty strings.

Alternatively, if we want to explicitly opt into the managed identity approach as suggested here, maybe the existing 'default' block (using default credentials in storageQueueManager) should be removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is in cdConfig.js:

connectionString: config.get('CRAWLER_QUEUE_AZURE_CONNECTION_STRING') || cd_azblob.connection

We have to specify the connection string because it's a different account from cd_azblob, but if we specify the connection string it's going to use that for authentication. Adding another flag seemed like the cleanest way to maintain backwards compatibility with any existing uses of the crawler.

I think you're right that the existing 'default' block in storageQueueManager is not really reachable based on the values in cdConfig.js, but removing that default block would break compatibility if there's anyone calling that code independent of cdConfig.js. Seems very unlikely, but I'm wary of making a change like that to save a small number of easily understood lines of code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to specify the connection string because it's a different account from cd_azblob

I see, that makes sense.

I'm wary of making a change like that to save a small number of easily understood lines of code

The line savings are small indeed, but it would make the code easier to understand, removing this very doubt that you bring (that someone might actually use that somehow). Less cognitive load is always good. But I'm not 100% against it, and I appreciate the concern, so we can leave it there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt anyone uses this code without cdConfig.js but I see why you have done what you have.

@ljones140 ljones140 mentioned this pull request Mar 18, 2026

@ljones140 ljones140 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran integration tests on this and they passed

https://github.com/clearlydefined/operations/actions/runs/23259034268

const { account, spnAuth, isSpnAuth, useManagedIdentity } = options
const useManagedIdentityEnabled = useManagedIdentity === true || useManagedIdentity === 'true'

if (useManagedIdentityEnabled) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt anyone uses this code without cdConfig.js but I see why you have done what you have.

@elrayle
elrayle merged commit 11d0a38 into clearlydefined:master Mar 19, 2026
2 checks passed
@dangoor
dangoor deleted the dangoor/managed-identity branch March 19, 2026 14:12
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.

4 participants