我有以下Azure功能,或者至少是相关部分:
using Microsoft.Azure.Services.AppAuthentication;
using Microsoft.Azure.KeyVault;
using Microsoft.Azure.KeyVault.Models;
using System;
using System.Configuration;
using System.Data.SqlClient;
using System.Threading.Tasks;
public static async Task Run(TimerInfo myTimer, TraceWriter log)
{
AzureServiceTokenProvider tokenProvider = new AzureServiceTokenProvider();
var keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(tokenProvider.KeyVaultTokenCallback));
var secret = await keyVaultClient.GetSecretAsync("https://xxxxx.vault.azure.net/secrets/TwiloAccountSid");
...
}
当执行此操作时,我尝试检索机密时出现“拒绝访问”错误。 Azure功能已在托管服务标识中注册。看来还有别的事情要做。
答案 0 :(得分:2)