Azure Function + Rider Credential issue resulting in "Message: AKV10032" error

Viewed 176

I am trying to debug and work with an Azure function in Rider - this error only occurs when I run it locally, deploying the function to Azure works correctly.

When I run the this block of code

default_credentials = DefaultAzureCredential()
    keyvault = SecretClient(
        vault_url=azure_shared.key_vault,
        credential=default_credentials
    )

    api_key = keyvault.get_secret("apikey").value

I get the following error:

ClientAuthenticationError: (Unauthorized) AKV10032: Invalid issuer. Expected one of https://sts.windows.net/xxxxxx-xxxx-xxxx-xxxx-4a5f0358090a/, https://sts.windows.net/xxxxxx-xxxx-xxxx-xxxx-5f571e91255a/, https://sts
.windows.net/xxxxxx-xxxx-xxxx-xxxx-dee5fc7331f4/, found https://sts.windows.net/xxxxxx-xxxx-xxxx-xxxx-579c58293b4b/.

I only have one subscription. AZ ACCOUNT SHOW confirms the account I am logged in as is the one ending in 90a, so an expected account.

However, if I run AZ LOGIN and login with my work account, the tenantId is the b4b one.

Why the heck is Rider / Azure Functions using a different credential that I have provided? Is it stored somewhere locally?

1 Answers

Thank you JamesTran-MSFT | Microsoft Docs and User Madhanlal - Stack Overflow Stack Overflow. Posting your suggestions as answer to help other community members.

You can try below way to resolve AKV10032: Invalid issuer. Expected one of https://sts.windows.net/... error:

This error could be cross-tenant issue;
If you set the sub as default just before, it should work:

az account set --subscription {SubID}
az keyvault secret list --vault-name myVault  

Re-execuate the code:

default_credentials = DefaultAzureCredential()
keyvault = SecretClient(
vault_url=azure_shared.key_vault,
credential=default_credentials
)
api_key = keyvault.get_secret("apikey").value

References: Unable to retrieve password from keyvault - ERROR: AKV10032: Invalid issuer - Microsoft Q&A and How to solve azure keyvault secrets (Unauthorized) AKV10032: Invalid issuer. error in Python - Stack Overflow

Related