问题描述

在使用 Key Vault 和 Azure CLI 管理存储帐户密钥的官方文档中,其中有一步是“向 Key Vault 授予对你的存储帐户的访问权限”, 其中CLI命令中使用的--assignee-object-id参数值为2330fcd0-aceb-49c4-a58f-27980b31efc5,根据说明其值为Azure 中国云中 Key Vault 的对象 ID,固定不变。但是在执行时,则出现如下错误:

Principal 2330fcd0aceb49c4a58f27980b31efc5 does not exist in the directory xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

完整的错误消息体为:

### 1
az role assignment create --role "Storage Account Key Operator Service Role" --assignee-object-id "xxxxxxxx-xxxx-xxxx-xxxx-efe0ge7cxxxx" --scope "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testrg/providers/Microsoft.Storage/storageAccounts/testsa01"
报错:
Failed to query --assignee-principal-type for xxxxxxxx-xxxx-xxxx-xxxx-efe0ge7cxxxx by invoking Graph API.
RBAC server might reject creating role assignment without --assignee-principal-type in the future. Better to specify --assignee-principal-type manually.
Principal xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx does not exist in the directory xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

### 2

az role assignment create --role "Storage Account Key Operator Service Role" --assignee "https://vault.azure.cn" --scope "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testrg/providers/Microsoft.Storage/storageAccounts/testsa01"
报错:
Cannot find user or service principal in graph database for 'https://vault.azure.cn'. If the assignee is an appId, make sure the corresponding service principal is created with 'az ad sp create --id https://vault.azure.cn'

问题原因

文档描述错误,Azure中国云为Key Vault注册的对象ID(Object)并不是固定不变,在每个不同的租户下,其值不同。只有Key Vault中Application ID保持不变。正如文档中描述的:

解决办法

根据Azure Key Vault的应用程序ID获取在Azure AAD中查找到正确的Object ID。然后执行az role assignment create命令

az role assignment create --role "Storage Account Key Operator Service Role" --assignee-object-id <right key vault object id in AAD> --scope "/subscriptions/<subscriptionID>/resourceGroups/<StorageAccountResourceGroupName>/providers/Microsoft.Storage/storageAccounts/<YourStorageAccountName>"

获取Key Vault的Object ID方式如下:

第一步:进入Azure AD, 在overview页面搜索key vault的application id(此ID为固定值 cfa8b339-82a2-471a-a3c9-0fc0be7a4093,见:https://docs.azure.cn/zh-cn/key-vault/secrets/overview-storage-keys#service-principal-application-id)

第二步:点击进入Key Vault页面查看Object ID

第三步:获取到Key Vault的Object ID后,执行CLI命令成功

参考文档

使用 Key Vault 和 Azure CLI 管理存储帐户密钥https://docs.azure.cn/zh-cn/key-vault/secrets/overview-storage-keys#give-key-vault-access-to-your-storage-account

【Azure 环境】如何解决Principal 2330xxxxxxxxxxxxxxxxxxxx31efc5 does not exist in the directory xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx问题的更多相关文章

  1. 【Azure Developer】解决Azure Key Vault管理Storage的示例代码在中国区Azure遇见的各种认证/授权问题 - C# Example Code

    问题描述 使用Azure密钥保管库(Key Vault)来托管存储账号(Storage Account)密钥的示例中,从Github中下载的示例代码在中国区Azure运行时候会遇见各种认证和授权问题, ...

  2. 【Azure 环境】使用Microsoft Graph PS SDK 登录到中国区Azure, 命令Connect-MgGraph -Environment China xxxxxxxxx 遇见登录错误

    问题描述 通过PowerShell 连接到Microsoft Graph 中国区Azure,一直出现AADSTS700016错误, 消息显示 the specific application was ...

  3. 【Azure 环境】【Azure Developer】使用Python代码获取Azure 中的资源的Metrics定义及数据

    问题描述 使用Python SDK来获取Azure上的各种资源的Metrics的名称以及Metrics Data的示例 问题解答 通过 azure-monitor-query ,可以创建一个 metr ...

  4. ASP.NET 在 Windows Azure 环境中使用基于 SQLServer 的 Session

    Session 嘛,占一点儿服务器资源,但是总归比 ViewState 和 Cookie 安全点儿,所以还是要用的. Windows Azure 环境中的 Web 服务器经由负载均衡调度,根本无法保证 ...

  5. 搭建php环境时解决jpeg6 make: ./libtool:命令未找到

    搭建php环境时解决jpeg6 make: ./libtool:命令未找到 [root@bogon jpeg-6b]# make; make install ./libtool --mode=comp ...

  6. Azure环境中Nginx高可用性和部署架构设计

    前几篇文章介绍了Nginx的应用.动态路由.配置.在实际生产环境部署时,我们需要同时考虑Nginx的高可用性和部署架构. Nginx自身不支持集群以保证自身的高可用性,商业版本的Nginx+推荐: T ...

  7. php-cgi和php-fpm,Windows环境下解决Nginx+php并发访问阻塞问题。

    php-cgi 是运行php,php-fpm是守护php-cgi进程 nginx配置目录运行php        location  ~ \.php$        {                 ...

  8. 部署Azure环境Web应用程序不能直接访问JSON文件解决方案

    问题: 部署在Azure环境Web应用程序的JSON文件,直接通过浏览器或Web应用访问出现 404 的错误信息. 以下通过Firfox浏览器直接访问JSON文件返回的提示错误信息: “HTML 文档 ...

  9. SQLBackupAndFTP The server principal "NT AUTHORITY\SYSTEM" is not able to access the database "xxxx"

    Windows server 2012中使用SQLBackupAndFTP备份数据库时遇到一个错误: ERROR: The server principal "NT AUTHORITY\SY ...

  10. 【Azure Developer】使用 Azure Python SDK时,遇见 The resource principal named https://management.azure.com was not found in the tenant China Azure问题的解决办法

    问题描述 在使用Python SDK时候,登录到China Azure (Mooncake)并访问AlertsManagement资源时候,时常遇见  EnvironmentCredential: A ...

随机推荐

  1. Oracle 设置白名单过滤

    最近有一个需求  要求开发人员不能随便连接测试的数据库 又不想太过复杂,部分人还得进行连结. 查了下往上是有方案的: 就是 TCP_VALIDNODE_CHECKING 参数 解决方法和说明如下 来源 ...

  2. 【DS】【AtCoder】Pakencamp 2022 Day2 H

    2023.6.30 Problem Link 有 \(n\) 个帮派在打架,每个帮派有一个大小 \(a_i\),每相邻两个帮派有一个仇恨度 \(b_i\).现在有 \(Q\) 次单点修改 \(a_i\ ...

  3. Spring Boot接口设计

    项目文件结构 编写示例代码 添加lombok的依赖 新建DemoController,用于提供RESTful接口.增加相关注解:@RestController,@RequestMapping(&quo ...

  4. iframe 框架技术

    隐性转发 <!doctype html> <html lang="zh_CN"> <head> <meta charset="u ...

  5. 在Unity中使用SQLite保存配置表数据(For Lua)

    在Lua中使用sqlite Lua版本Sqlite文档:http://lua.sqlite.org/index.cgi/doc/tip/doc/lsqlite3.wiki sqlite官网:https ...

  6. python3 ACM模式的输入输出例子教学

    Python的输入是字符串,所以要自己转类型 strip去掉左右两端的空白符,返回str slipt把字符串按空白符拆开,返回[str] map把list里面的值映射到指定类型,返回[type] EO ...

  7. [Elasticsearch] Elasticsearch 启动访问报错问题

    Elasticsearch 启动访问报错问题 产生的问题与解决方案 环境:Windows 10 ES 版本:8.12.0 现象: 双击 elasticsearch.bat 文件启动后,访问 http: ...

  8. Wireguard笔记(二) 命令行操作

    目录 Wireguard笔记(一) 节点安装配置和参数说明 Wireguard笔记(二) 命令行操作 Wireguard笔记(三) lan-to-lan子网穿透和多网段并存 命令行操作 创建wg0网卡 ...

  9. 【Unity3D】UGUI之Image和RawImage

    1 纹理(Texture) ​ Image 控件和 RawImage 控件都是承载渲染图片的控件,都需要指定一个纹理(Texture)图片.在 Assets 窗口选中一张图片,在 Inspector ...

  10. 【OpenGL ES】绘制魔方

    1 前言 ​ 在立方体贴图(6张图)中,绘制了一个立方体,贴了 6 张图,本文的魔方案例,将实现绘制 27个立方体,贴 162 张图.贴图图片如下: ​ 说明:inside.png 为魔方内部色块,用 ...