【发布时间】:2020-10-19 18:57:45
【问题描述】:
我在资源组级别删除 Azure Lock 时遇到问题。我是通过 Azure Runbook 进行的。
我验证良好(我能够获取任何我想要的详细信息)。这是代码:
# Ensures you do not inherit an AzureRMContext in your runbook
Disable-AzContextAutosave –Scope Process
"Logging in to Azure..."
$connection = Get-AutomationConnection -Name AzureRunAsConnection
Connect-AzAccount -ServicePrincipal -Tenant $connection.TenantID -ApplicationId $connection.ApplicationID -CertificateThumbprint $connection.CertificateThumbprint
如果我这样做了,比如说Get-AzResource -ResourceGroupName $RG,我就会得到我需要的信息。但问题是我实际上需要删除该资源组的一些资源,并且它有一个锁。
当我Remove-AzResourceLock -LockId $getAzureLock.LockId -Force 时,我被抛出这个:
Remove-AzResourceLock : AuthorizationFailed : The client XX with object id XX does not have authorization to perform action 'Microsoft.Authorization/locks/delete' over scope '/subscriptions/<redacted>/resourceGroups/<redacted>/providers/Microsoft.Authorization/locks/resourceDellock' or the scope is invalid. If access was recently granted, please refresh your credentials.
仅供参考,我已编辑订阅/对象 ID 信息。
为了我的一生,我无法绕过它。从访问控制 (IAM) 将应用程序添加为订阅级别的贡献者。
我尝试了很多东西,我只是累了写下来!我很抱歉。在过去的 4 个小时里,我一直在阅读和尝试一些东西。所以请原谅我!
请帮我解决这个问题..
【问题讨论】:
-
顺便说一句,所有这些都可以从 VSCode 无缝运行。
标签: azure powershell azure-resource-group azure-runbook