Skip to content

[Identity] Remove version check for now, until other services support it#12164

Closed
sophiajt wants to merge 2 commits into
Azure:masterfrom
sophiajt:fix_12058
Closed

[Identity] Remove version check for now, until other services support it#12164
sophiajt wants to merge 2 commits into
Azure:masterfrom
sophiajt:fix_12058

Conversation

@sophiajt
Copy link
Copy Markdown
Contributor

We'd like to support more versions for MSI, but this currently isn't supported broadly enough to roll out. We'll use the older API version for now until we get broader support.

Fixes #12058

@sadasant
Copy link
Copy Markdown
Contributor

sadasant commented Nov 2, 2020

This PR will fix this instead: #11976

Copy link
Copy Markdown

@schaabs schaabs left a comment

Choose a reason for hiding this comment

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

LGTM

@sadasant
Copy link
Copy Markdown
Contributor

sadasant commented Nov 2, 2020

@schaabs please review this instead: #11976

@sadasant sadasant requested a review from schaabs November 2, 2020 22:37
@ghost ghost closed this in #11976 Nov 4, 2020
ghost pushed a commit that referenced this pull request Nov 4, 2020
#11976)

This PR does the following:

1. Simplifies the workflow of ManagedIdentityCredential, fixing #11653
2. Implements caching on the managed credential so that we only verify which MSI is available once per instance of this class. There's no issue for this, but this is necessary to align with .Net
3. Adds Azure Arc support, fixing #10235 
4. Adds Azure Fabric support, fixing #10238

### Simplifies the workflow of ManagedIdentityCredential

This is now how we pick what MSI credential is available:

```ts
const MSIs = [appServiceMsi2019, appServiceMsi2017, arcMsi, cloudShellMsi, imdsMsi];

for (const msi of MSIs) {
  if (await msi.isAvailable(this.identityClient, resource, clientId, getTokenOptions)) {
    this.cachedMSI = msi;
    return msi;
  }
}
```

Shows the order of verification more clearly. Reduces the complexity of the credential.

### Implements caching on the managed credential

The managed credential was verifying the availability of the MSIs on each request - except for the IMDS one, which had a very weird flow with a stateful boolean value that was passed through from method to method.

Instead of doing that, the first time we authenticate we define what MSI is available, and subsequent calls won't run any validation.

This aligns with .Net.

### Adds Azure Arc support

This PR also showcases the refactoring by how simple it is to add a new MSI to the main ManagedIdentityCredential class.

The notes on how I was able to write and test the Arc MSI are here: https://gist.github.com/sadasant/888dc7e88543a21ee7061997984dd207

The change on the ManagedIdentityCredential consists of adding `arcMsi` to the array of MSIs used inside of the `cachedAvailableMSI` function.

There's an important note on how I'm currently validating this environment here: [link](#11976 (comment)).

---

I'll leave this PR as draft until we find the time to do an internal review, then I'll move it out of draft.

Fixes #11653
Fixes #10235

**New:**
Fixes #11595
Fixes #10238
Closes #12164
Fixes #12058
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UnsupportedApiVersion using managed identity in Azure Functions

3 participants