无法在Azure中创建Azure部署插槽

时间:2020-09-29 10:09:26

标签: azure powershell octopus

我正在尝试通过Powershell脚本在Octopus中的Azure应用环境中创建插槽 这是我的脚本,

$resourceGroupName = $OctopusParameters["ResourceGroupName"]
$name = $OctopusParameters["Name"]
New-AzureRmWebAppSlot -ResourceGroupName $resourceGroupName -Name $name -Slot blue

它可以在开发环境中工作,但不能在UAT中工作。我可以确认两个环境相同。 我检查了所有内容,在天蓝色和八达通上看起来都一样

我得到的错误如下

Calamari.exe : CloseError: The client '976C13ED-5E0E-45C2-8E7A-6172CD41A523' with object id 
'976C13ED-5E0E-45C2-8E7A-6172CD41A523' does not have authorization to perform action 'Microsoft.Web/sites/read' over  
scope '/subscriptions/87932404-80E8-4895-8F4A-E400E263E3DF/resourceGroups/cyberton-app-uat/providers/Microsoft.Web/sit 
es/cyberton-app-uat' or the scope is invalid. If access was recently granted, please refresh your credentials. 
At C:\Octopus\Work\20200929095107-112805-2926\Bootstrap.ps1:49 char:1 
+ &  "C:\Octopus\OctopusServer\Tools\Calamari.Cloud\9.0.5\Calamari.exe" ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo          : NotSpecified: (CloseError: The...ur credentials.:String) [], RemoteException 
    + FullyQualifiedErrorId : NativeCommandError  
At C:\Octopus\Work\20200929095107-112805-2926\Script.ps1:7 char:1 
+ New-AzureRmWebAppSlot -ResourceGroupName $resourceGroupName -Name $name -Slot blue

我的想法不多了,请您帮忙

谢谢

1 个答案:

答案 0 :(得分:0)

您应该为服务主体'976C13ED-5E0E-45C2-8E7A-6172CD41A523'分配订阅角色。

在Azure门户中,找到您的Azure订阅,单击Access Control (IAM),然后单击Add role assignment。为服务主体分配一个角色(例如,参与者)。

enter image description here

如果您认为订阅角色的权限太大,则可以找到相应的资源来执行相同的角色分配操作。