Azure 存储:BlobClient:使用 DefaultCredential 在本地下载 Visual Studio:颁发者验证失败。发行人不匹配
Azure Storage: BlobClient: Download using DefaultCredential locally with Visual Studio: Issuer validation failed. Issuer did not match
我想使用 Visual Studio (2022) 从本地计算机的 Azure 存储帐户中的私有容器下载 Blob。
为了实现我正在使用
DefaultAzureCredential credential = new DefaultAzureCredential();
Uri uri = new Uri("https://xxx.blob.core.windows.net/xxx/xxx.json");
BlobClient blobClient = new BlobClient(uri, credential);
Response<BlobDownloadResult> downloadResponse = blobClient.DownloadContent();
当我执行代码时出现以下错误
Issuer validation failed. Issuer did not match.
我按照此处所述在 VS 2022 中进行了身份验证:
我需要做什么才能成功下载 Blob?
如 https://docs.microsoft.com/en-us/dotnet/api/azure.identity.defaultazurecredential?view=azure-dotnet 中所述,DefaultAzureCredential 会尝试不同的选项来获取凭据,其中之一是 VisualStudioCredential。
为了让它在本地工作,我必须提供 VisualStudioTenantId:
DefaultAzureCredentialOptions defaultAzureCredentialOptions = new DefaultAzureCredentialOptions()
{
VisualStudioTenantId = "xxx"
};
DefaultAzureCredential credential = new DefaultAzureCredential(defaultAzureCredentialOptions);
Uri uri = new Uri("https://xxx.blob.core.windows.net/xxx/xxx.json");
BlobClient blobClient = new BlobClient(uri, credential);
Response<BlobDownloadResult> downloadResponse = blobClient.DownloadContent();
我想使用 Visual Studio (2022) 从本地计算机的 Azure 存储帐户中的私有容器下载 Blob。
为了实现我正在使用
DefaultAzureCredential credential = new DefaultAzureCredential();
Uri uri = new Uri("https://xxx.blob.core.windows.net/xxx/xxx.json");
BlobClient blobClient = new BlobClient(uri, credential);
Response<BlobDownloadResult> downloadResponse = blobClient.DownloadContent();
当我执行代码时出现以下错误
Issuer validation failed. Issuer did not match.
我按照此处所述在 VS 2022 中进行了身份验证:
我需要做什么才能成功下载 Blob?
如 https://docs.microsoft.com/en-us/dotnet/api/azure.identity.defaultazurecredential?view=azure-dotnet 中所述,DefaultAzureCredential 会尝试不同的选项来获取凭据,其中之一是 VisualStudioCredential。
为了让它在本地工作,我必须提供 VisualStudioTenantId:
DefaultAzureCredentialOptions defaultAzureCredentialOptions = new DefaultAzureCredentialOptions()
{
VisualStudioTenantId = "xxx"
};
DefaultAzureCredential credential = new DefaultAzureCredential(defaultAzureCredentialOptions);
Uri uri = new Uri("https://xxx.blob.core.windows.net/xxx/xxx.json");
BlobClient blobClient = new BlobClient(uri, credential);
Response<BlobDownloadResult> downloadResponse = blobClient.DownloadContent();