我想使用 RBAC 连接到 Azure 表存储。我已在门户中完成角色分配,但找不到连接到 Azure 表表单 .NET 代码的方法。我可以找到很多有关如何连接到 BlobClient 的文档
static void CreateBlobContainer(string accountName, string containerName)
{
// Construct the blob container endpoint from the arguments.
string containerEndpoint = string.Format("https://{0}.blob.core.windows.net/{1}",
accountName,
containerName);
// Get a token credential and create a service client object for the blob container.
BlobContainerClient containerClient = new BlobContainerClient(new Uri(containerEndpoint),
new DefaultAzureCredential());
// Create the container if it does not exist.
containerClient.CreateIfNotExists();
}
但找不到 Azure Table Acess 的类似文档。
以前有人这样做过吗?
最佳答案
当前一代 Azure SDK 的 Azure Active Directory 和其他 token 源授权模式基于 Azure.Identity
包中的凭据。
对于表格,您共享的代码片段的大致等效内容如下所示:
// Construct a new TableClient using a TokenCredential.
var client = new TableClient(
new Uri(storageUri),
tableName,
new DefaultAzureCredential());
// Create the table if it doesn't already exist to verify we've successfully authenticated.
await client.CreateIfNotExistsAsync();
更多信息可以在Azure Tables authorization sample中找到和 Azure.Identity library overvivew .
关于azure - 如何使用 RBAC 连接到 Azure 表存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71444167/