[英]Azure Automation: VM shutdown runbook not working on new VM
I recently had to delete and re-install my VM due to an issue with the VM locking up. 由于VM锁定问题,最近我不得不删除并重新安装VM。 Now that the VM is back online, I noticed the shutdown automation is not working.
现在,虚拟机已恢复联机状态,我注意到关机自动化无法正常工作。 It was working fine before I ran into the issue with the VM.
在遇到虚拟机问题之前,它运行良好。 Below is the PS script from the runbook, it returns the following error:
以下是Runbook的PS脚本,它返回以下错误:
Correlation ID: 72fa8e58-89f1-4612-bc43-1b05876c2bff
Timestamp: 2015-08-25 06:04:14Z: The remote server returned an error: (401) Unauthorized.
At Shutdown:6 char:6
+
+ CategoryInfo : CloseError: (:) [Add-AzureAccount], AadAuthenticationFailedException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount
8/24/2015 11:04:25 PM, Error: Get-azurevm : No default subscription has been designated.
Use Select-AzureSubscription -Default <subscriptionName> to set the default subscription.
At Shutdown:8 char:8
+
+ CategoryInfo : CloseError: (:) [Get-AzureVM], ApplicationException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureVMCommand
Any idea what I am missing to get this working with new VM? 知道我要与新VM一起使用时缺少什么吗? I have been wracking my brain for something with the credentials that would not include this new VM, but have come up empty handed.
我一直在为某些不包含此新VM的凭据而费劲,但是空手而归。
workflow Shutdown
{
$Cred = Get-AutomationPSCredential -Name "auto"
Add-AzureAccount -Credential $Cred
$vms = Get-azurevm
foreach($VM in $VMS)
{
$VMName = $VM.Name
Stop-AzureVM -ServiceName $VM.ServiceName -Name $VM.Name -Force
Write-Output "Shutting down VM : $VMName "
}
}
I think you should also add the subscription name (select-azuresubscription in the error log) in the script you are using. 我认为您还应该在所使用的脚本中添加订阅名称(错误日志中的select-azuresubscription)。 There are quite some examples of doing this in various ways in the TechNet Script libraries like this one https://gallery.technet.microsoft.com/scriptcenter/Stop-Azure-VM-with-OrgID-41a79d91
在诸如此类的TechNet脚本库中,有许多以各种方式执行此操作的示例,例如https://gallery.technet.microsoft.com/scriptcenter/Stop-Azure-VM-with-OrgID-41a79d91
I created a new user, granted them admin rights to the subscription, and updated the credential. 我创建了一个新用户,授予他们管理权限认购,并更新了证书。 That seemed to fix it, guessing it was something with the existing co-admin account not having access to the new VM.
似乎可以解决此问题,因为现有的共同管理员帐户无法访问新的VM可能导致了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.