azure - 如何使用 RBAC 连接到 Azure 表存储

标签 azure azure-active-directory azure-table-storage rbac

我想使用 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/

相关文章:

powershell - Switch-AzureMode AzureResourceManager 无法识别

azure - azure 用户 session 生命周期

spring - 无法在 Java Spring Boot 中使用用户管理身份访问应用程序配置

python - Python 中的 Azure Table Take(N) 方法

.net - 在 Azure 辅助角色中启动可执行文件 : path problems

azure - 在没有flask的情况下在azure中运行python函数

performance - 在没有存储帐户支持的情况下远程收集Azure诊断日志

Azure CLI : get object id from user name or email address

azure - 列出存储帐户中的所有 azure 表

azure - 当 Azure 表存储主区域失败时,CloudTableClient.BaseUri.AbsoluteUri 值是否会更改?