Search code examples
azureazure-functionsazure-keyvault

How can we get tenant id, client id and client secret for Azure Function App?


I am going use key vault for Azure Function App.

I am using .NET SDK.

  1. Azure.Security.KeyVault.Secrets
  2. Azure.Identity

Example:

string keyVaultUrl = configuration["KeyVaultSettings:Url"];

            TokenCredential credential = new DefaultAzureCredential();
#if DEBUG
            credential = new ClientSecretCredential(configuration["AZURE_TENANT_ID"],
                                                    configuration["AZURE_CLIENT_ID"],
                                                    configuration["AZURE_CLIENT_SECRET"]);
#endif

            var secretClient = new SecretClient(new Uri(keyVaultUrl), credential);

To debug locally I need

tenant_id, client_id, and client_secret.

How Can i get this?


Solution

  • I assume you have Authentication turned on in your Function App. Go to App Registration of the function app and for steps to fetch Client Id, Tenant Id and Client Secret, you can refer to this and this