botbuilder-dotnet: When using skills with user assigned managed identity , the msi endpoint fails with a 500
Version
Latest
Describe the bug
When using user assigned managed identity in azure app service, invoking a skill fails when requesting a token from the msi endpoint (http://127.0.0.1:41120/msi/token/?api-version=2019-08-01&resource=<redacted>&client_id=<redacted>) - which returns a HTTP 500 (with no detail) followed by the error below:
Failed to acquire token for client credentials. ([Managed Identity] Error Message: An unexpected error occurred while fetching the AAD Token. Managed Identity Correlation ID: 3b30b8c8-c05d-47d4-9e4b-c74af665aadc Use this Correlation ID for further investigation.)
To Reproduce
This is happening in our production system (where previously provisioned bots have been working), I have also reproduced it with a minimal repro on the bot builder skills sample
-
Clone this repo and open the
samples/csharp_dotnetcore/80.skills-simple-bot-to-bot -
You will need to setup the following in Azure (using the standard User assigned managed identity stuff)
- An azure bot configured with User Assigned Managed Identity for the root
- An azure bot configured with User Assigned Managed Identity for the child
- A webapp for the root (parent), set it to use User assigned managed identity of the root bot. Also set the
AZURE_CLIENT_IDapplication setting to point to the root bot managed identity client id . - A webapp for the child, set it to use User assigned managed identity of the child bot. Also set the
AZURE_CLIENT_IDapplication setting to point to the child bot managed identity client id . - Set the messaging endpoints in the parent and root bot according to the sample
- Now edit the appsettings in the
EchoSkillBot(which will be deployed to the child webapp) to
{
"MicrosoftAppType": "UserAssignedMSI",
"MicrosoftAppTenantId": "<tenant id>",
"MicrosoftAppId": "<child managed identity client id>",
"AllowedCallers": [ "*" ]
}
- Now edit the appsettings in the
SimpleRootBot(which will be deployed to the root webapp) to
{
"MicrosoftAppType": "UserAssignedMSI",
"MicrosoftAppTenantId": "<tenant id>",
"MicrosoftAppId": "<parent managed identity client id>",
"SkillHostEndpoint": "https://<root webapp domain>/api/skills/",
"BotFrameworkSkills": [
{
"Id": "EchoSkillBot",
"AppId": "<child managed identity client id>",
"SkillEndpoint": "https://<child webapp domain>/api/messages"
}
]
}
- Publish both projects to their corresponding webapps
- Test the parent bot in the Azure bot resource, type
skill, you will see the following
ℹ️ If you look in the parent appinsights, you will see the error
Expected behavior
It should authenticate and communicate with the skill as expected.
Additional context
Please reach out if you need any further info, screen shares etc.
This is impacting a few of our customers, so is high priority for us. Thank you!
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 55 (17 by maintainers)
I don’t have a lot of context here, but Microsoft recently started blocking MSI as Audience in a token. Tenants that were using this flow before/around April, should be on an allow list.
Same error here. Some more details on the error:
http://127.0.0.1:41120/msi/token/?api-version=2019-08-01&resource=<redacted>&client_id=<redacted>) is called passing:resource=<child managed identity client id>client_id=<parent managed identity client id>i went for a different approach for getting my project up and running again, you can check the details here : https://feng.lu/2024/09/18/How-to-secretless-access-Azure-and-AWS-resources-with-Azure-managed-identity-and-AWS-IAM/
It does require creating an app in entra id, so I guess it is not helpline you @jamesemann ?
I also encountered this error “can not use Managed Service Identity (MSI) as audience in token as it is unsupported. MSI should not be set as audience as it does not accept tokens” while the code worked perfectly a few months back.
Sorry for not paying attending to any announcement of this change in Entra ID, but what is the recommended alternative that is close to the managed identity approach?
thanks
Ok, thanks for that information, We will chat about this internally.
@jamesemann Thanks. I wouldn’t expect there to be a difference in the SDK versions, rather checking out the MSAL dependencies in use.
@jamesemann I created new ones, which is what the ARM templates do. I have confirmed that our support folks can’t get the Skill to work. It remains a mystery why mine do. I have confirmed both Root and Skill are MSI.
@jamesemann Still conferring with some about this.
@jamesemann Ya. I wouldn’t expect any changes between those two versions. Was trying to isolate if a major jump in SDK version had been made. Like from 4.18 to 4.22 or something larger. We will get setup to repro. Worth noting, we haven’t made any explicit changes to this. But dependency changes can be wicked on occasion.
Hi @ceciliaavila @tracyboehrer would it be possible to triage this item? This is very high priority for our customers