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.

Connect to KeyVault in Azure China

See original GitHub issue

Library name and version

Azure.Security.KeyVault.Certificates 4.2.0

Query/Question

I use this code for Azure KeyVault Service and it works well with a regular Azure

    ClientSecretCredential clientCredential = new(options.KeyVaultTenantId, options.KeyVaultClientId, options.KeyVaultClientSecret);
    KeyVaultCertificateWithPolicy rootCertificate = new CertificateClient(vaultUri, _clientCredential).GetCertificate(_rootCertificateId).Value;

however, I need to connect to Azure China. The code fails with message:

AADSTS90002: Tenant ‘xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx’ not found. Check to make sure you have the correct tenant ID and are signing into the correct cloud. Check with your subscription administrator, this may happen if there are no active subscriptions for the tenant

I found this but I don’t know where to set ActiveDirectoryServiceSettings.AzureChina in my code. Please suggest

    <PackageReference Include="Azure.Identity" Version="1.5.0" />
    <PackageReference Include="Azure.Security.KeyVault.Certificates" Version="4.2.0" />
    <PackageReference Include="Azure.Security.KeyVault.Keys" Version="4.2.0" />
    <PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.2.0" />

Environment

.NET SDK (reflecting any global.json): Version: 6.0.201 Commit: ef40e6aa06

Runtime Environment: OS Name: Windows OS Version: 10.0.19044 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.201\

Host (useful for support): Version: 6.0.3 Commit: c24d9a9c91

.NET SDKs installed: 5.0.404 [C:\Program Files\dotnet\sdk] 6.0.100 [C:\Program Files\dotnet\sdk] 6.0.201 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 5.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
heathscommented, Apr 13, 2022

In the link I provided above: https://docs.microsoft.com/dotnet/api/azure.identity.tokencredentialoptions.authorityhost?view=azure-dotnet#azure-identity-tokencredentialoptions-authorityhost

Using a different environment (cloud) is similar across our different language SDKs. Everything defaults to AzureCloud because that is, by far, the most used cloud. Same for the az CLI and Az PowerShell cmdlets.

0reactions
msftbot[bot]commented, Apr 13, 2022

Hi @Marusyk. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connect to KeyVault in Azure China
1 Answer. You would need to use ClientSecretCredential(String, String, String, ClientSecretCredentialOptions) constructor override and set the ...
Read more >
Access Azure Key Vault behind a firewall
Accessing and managing objects (keys and secrets) stored in Key Vault itself, going through the Key Vault-specific endpoint (for example, https ...
Read more >
C# AzureSDK SecretClient how to authenticate against ...
I am trying to get some secrets from a KeyVault in AzureChinaCloud. ... KeyVault address to one in China it no longer works....
Read more >
Azure China developer guide
There are tools and documents to help developers create and deploy cloud applications to Microsoft Azure operated by 21Vianet (Azure China).
Read more >
Azure Key Vault security overview
Azure Key Vault protects cryptographic keys, certificates (and the private keys associated with the certificates), and secrets (such as ...
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