Deployment info for .NetCore 8 to Azure app service #1491
Unanswered
HBSbwilliamson
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Can we add a document section for deployment to an Azure App Service as a web API including storing the auth cert in Azure Key Vault?
string connectionString = builder.Configuration["AzureAD:VaultUri"];
var keyVaultEndpoint = new Uri(connectionString);
var kvClient = new SecretClient(keyVaultEndpoint, new DefaultAzureCredential());
var kvSecret = await kvClient.GetSecretAsync("cert-name");
var kvClientCert = new CertificateClient(keyVaultEndpoint, new DefaultAzureCredential());
var cert = kvClientCert.GetCertificateAsync("cert-name").ConfigureAwait(false).GetAwaiter().GetResult();
var cert_content = cert.Value.Cer;
// This call using GetCertificateAsync returns a certificate without a private key
X509Certificate2 x509 = new X509Certificate2(cert_content);
// This call using GetSecretAsync returns a certificate with the private key (required)
X509Certificate2 x509certificate = new X509Certificate2(Convert.FromBase64String(kvSecret.Value.Value));
builder.Configuration.AddAzureKeyVault(keyVaultEndpoint, new DefaultAzureCredential());
Beta Was this translation helpful? Give feedback.
All reactions