AppAuthentication 1.1.0-preview: TenantId is mandatory in connection string with RunAs=App
See original GitHub issueThe ClientCertificateAzureServiceTokenProvider
seams to only use the tenant id in its method GetTokenAsync
if the authority
parameter is null or white space. But some clients, for example the KeyVaultClient
of Microsoft.Azure.KeyVault
, provides a authority
parameter. This makes the TenantId
-part of the connection string possibly redundant.
For example, the following code works just fine:
var azureServiceTokenProvider = new AzureServiceTokenProvider(
$"RunAs=App;AppId={appId};TenantId=NotNeeded;CertificateThumbprint={thumbprint};CertificateStoreLocation=CurrentUser");
var keyVaultClient = new KeyVaultClient(
new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
var secret = await keyVaultClient.GetSecretAsync(secretIdentifier).ConfigureAwait(false);
I propose making the TenantId
optional and instead throw in ClientCertificateAzureServiceTokenProvider.GetTokenAsync
if authority is null or white space and _tenantId
is not set.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Even without passing a connection string to ...
However, when I try to run this from a VM which has a managed identity, I get Connection string RunAs=App;AppId={myMSIID} is not valid....
Read more >AppAuthentication to Azure.Identity Migration Guidance
In this article ; (Default) environment-based, Default - no connection string used, new DefaultAzureCredential()* ; Azure CLI, RunAs=Developer;
Read more >App Authentication client library for .NET - version 1.6.0
To authenticate with a user-assigned identity, you need to specify the Client ID of the user-assigned identity in the connection string.
Read more >authenticate ASP.Net App on Azure WS2019 against ...
"AzureServicesAuthConnectionString" to "RunAs=App", the Prov. is only trying to get the token through Managed Identity method. The following ...
Read more >Azure SQL Database connection strings
Connection strings for Azure SQL Database. Connect using Microsoft.Data.SqlClient, SqlConnection, MSOLEDBSQL, SQLNCLI11 OLEDB, SQLNCLI10 OLEDB.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the feedback. I agree, the TenantId should not be mandatory if it will not be used in some scenarios. We will make a change in a future release to make it optional in the connection string, and throw in GetTokenAsync, if it is needed for that scenario.
Closing this as per the details provided above.