简体   繁体   中英

Azure App Service with User-assigned identity: retrieve clientId in the app?

I am running an Azure App Service with one User-assigned identity (and no system-managed identity): 在此处输入图像描述

Is there a way inside the app (ie my custom code) to retrieve the clientId of the identity? Or do I need to set that in a app setting to be available inside the app?

Question comes from the fact that I want to use this identity to authenticate using an AzureCredential and it needs the clientId.

Or is the better way to use MSI and set the app setting AzureServicesAuthConnectionString ?

Looking at environment variables in an App Service with a User assigned Managed Identity, there is nothing that contains the id.

So you should set the id as an App Setting on the app, and use it. I definitely recommend that you use AzureCredential as it is the newer one. The older AzureServiceTokenProvider would not give you any advantage over it anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM