Avi Siboni
Avi Siboni

Reputation: 814

Access to Azure Key Vault reference value from App Configuration in development on local

I have come across with the Azure App Configuration service, with the ability to link secret from Azure KeyVault, by creating a new record with an option of Key Vault reference.

I have used Microsoft extension for App Configuration as described in Microsoft Doc

The Steps that have been done

The issue is started when I trying to fetch data from App Configuration that have at least one KV reference. I'm getting the following error(only in case of that, one KV reference is linked to the App Configuration)

Service request failed. Status: 401 (Unauthorized)

Content:

{"error":"invalid_client","error_description":"AADSTS7000215: Invalid client secret is provided.\r\nTrace ID: \r\nCorrelation ID: \r\nTimestamp: 2020-05-27 22:59:52Z","error_codes":[7000215],"timestamp":"2020-05-27 22:59:52Z","trace_id":"","correlation_id":"","error_uri":"https://login.microsoftonline.com/error?code=7000215"}

Headers:
Cache-Control: no-store, no-cache
Pragma: no-cache
Strict-Transport-Security: REDACTED
X-Content-Type-Options: REDACTED
x-ms-request-id: REDACTED
x-ms-ests-server: REDACTED
P3P: REDACTED
Set-Cookie: REDACTED
Date: Wed, 27 May 2020 22:59:51 GMT
Content-Type: application/json; charset=utf-8
Expires: -1
Content-Length: 471

Any help will much appreciate :) Thanks!

Upvotes: 1

Views: 1996

Answers (2)

Avi Siboni
Avi Siboni

Reputation: 814

The issue was, that Visual Studio wasn't able to get the Environment Variable from some reason so it does not send with the request, once I ran the Visual Studio as Admin it works

Upvotes: 1

Heath
Heath

Reputation: 3292

When using the DefaultAzureCredential, it will first try Managed Identity (recommended for services on Azure), and eventually a service principal that requires the following environment variables to be set for the process (both on your application service, as well as for local development - can be different, so long as the service principal ID has appropriate permissions):

  • AZURE_TENANT_ID : the tenant ID
  • AZURE_CLIENT_ID : the service principal ID
  • AZURE_CLIENT_SECRET : the service principal secret (password) you were shown only after creating the service principal

You could also use the new preview of Azure.Identity which supports other authentication schemes more common and easier to use on development machines, such as the Azure CLI (az login), Visual Studio, and Visual Studio Code.

Upvotes: 4

Related Questions