powershell - 引发了“Microsoft.Rest.Azure.CloudException”类型的异常
问题描述
我正在尝试使用 VSTS 在 Web 应用程序上分配角色,但显示以下错误。
电源外壳 :
$webappname = "devt002"
$resourcegroup = "devt002RG"
#Get webapp object id
$webapp = Get-AzureRmWebApp -ResourceGroupName "$resourcegroup" -Name "$webappname"
$objectid = [System.Guid]::Parse($webapp.Identity.PrincipalId)
write-host "Object ID datatype :" $objectid.GetType().FullName
write-host "Object ID :" $objectid
#Get Assign role if already exist
$roles = Get-AzureRmRoleAssignment -ObjectId $objectid
write-host "Already Assigned Roles :" $roles.RoleDefinitionName
错误 :
2019-04-05T11:20:23.7408185Z ##[debug]Caught exception from task script.
2019-04-05T11:20:23.7408790Z ##[debug]Error record:
2019-04-05T11:20:23.7408993Z ##[debug]Get-AzureRmRoleAssignment : Exception of type 'Microsoft.Rest.Azure.CloudException' was thrown.
注意:它在本地 powershell 客户端中运行良好。仅与 VSTS 相关。
解决方案
检查您是否提供了正确的对象 ID。如果您通过变量提供对象 ID,则需要更改值。
推荐阅读
- python - 在 QProgressBar 内添加文本和完成百分比
- binary - 无法理解如何将虚拟地址转换为二进制形式
- c - 如何使用valgrind检测自定义alloc/free的内存泄漏?
- c++ - 在 C++ 中将函数获取和设置为虚拟函数
- python - 使用 Python Hashlib 从两个相同文件计算文件某些部分的 MD5 时结果不同
- javascript - 我如何获得一个新号码来生成
- javascript - 如何删除 [ 和 ] 以及两者之间的任何内容(javascript)
- python - 使用属性覆盖 setter:TypeError:'int' object is not callable
- python - 使用 Pandas 中的 apply 函数来使用每行的正则表达式计数
- python - 如何使用异常只允许 0 和 1 的字符串二进制输入并拒绝其他所有内容?