问题描述
谁能告诉我为什么在尝试运行此命令并将自定义角色“Secret Reader”分配给访客帐户对象 ID 时出现此错误:
az role assignment create --role "Secret Reader" --assignee-object-id "12526c57-c91b-405b-9068-2b582b23e83a" --scope "/subscriptions/Not-putting this-here/resourceGroups/pallabdev/提供商/Microsoft.keyvault/vaults/testhalvault"
我得到的错误是:
request Failed: Error occurred in request.,InvalidSchema: No connection adapters were found for 'C:/Program Files/Git/subscriptions/Not-Putting-This-Here/resourceGroups/pallabdev/providers/Microsoft.keyvault/vaults/testhalvault/providers/Microsoft.Authorization/roleDeFinitions?$filter=roleName%20eq%20%27Secret%20Reader%27&api-version=2018-01-01-preview'
解决方法
从错误信息来看,我假设你在 Windows 的 Git Bash 中运行了命令,我也可以在我这边重现,这是由 Git Bash 中的 Auto-translation of Resource IDs 引起的,类似问题 here .
要解决这个问题,只需在运行命令时设置环境变量MSYS_NO_PATHCONV=1
或临时设置即可。
$ MSYS_NO_PATHCONV=1 az role assignment create --role "Secret Reader" --assignee-object-id "12526c57-c91b-405b-9068-2b582b23e83a" --scope "/subscriptions/Not-putting this-here/resourceGroups/pallabdev/providers/Microsoft.KeyVault/vaults/testhalvault"