0
votes

Running the following code in Azure App service, which try to get details of a cloud service in the same Azure subscription, and get the exception about Certificate is is not associated with the subscription.

Although, under the subscription blade, under "Management certificates" the certificate does exists and authorized.

X509Store certStore = new X509Store(StoreName.My, storeLocation);
                    certStore.Open(OpenFlags.ReadOnly);


X509Certificate2Collection certCollection = certStore.Certificates.Find(X509FindType.FindByThumbprint, prodThumbprint, false);
                    if (certCollection.Count > 0)
                        CredentialsProd = new CertificateCloudCredentials(DBConstants.AZURE_SUBSCRIPTION_ID_PROD, certCollection[0]);

        using (var client = new ComputeManagementClient(Credentials))
         {
             var t = client.HostedServices.GetDetailedAsync(serviceName, CancellationToken);
         }

The exception:

ForbiddenError: The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription.

The certificate in the subscription: enter image description here

The certificate in the App service enter image description here

1

1 Answers

0
votes

To use a certificate that is uploaded to or imported into App Service, first make it accessible to your application code. You do this with the WEBSITE_LOAD_CERTIFICATES app setting. For more detail information, please refer to Use an SSL certificate in your application code in Azure App Service.

Add an app setting called WEBSITE_LOAD_CERTIFICATES and set its value to the thumbprint of the certificate. To make multiple certificates accessible, use comma-separated thumbprint values. To make all certificates accessible, set the value to *.

enter image description here