question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AppAuthentication 1.1.0-preview: TenantId is mandatory in connection string with RunAs=App

See original GitHub issue

The 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:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
varunsh-codercommented, Apr 16, 2018

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.

0reactions
varunsh-codercommented, Apr 10, 2019

Closing this as per the details provided above.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found