新しい Resource Manager を使用していくつかの Azure VM を作成しましたが、それらを毎日停止したいと考えています。
そのために、クラシック VM と ARM VM の両方を停止する Runbook を公開し、Runbook を毎晩実行するスケジューラを作成しました。
workflow Stop-AzureVMs
{
$cred = Get-AutomationPSCredential -Name 'Cred'
Add-AzureAccount -Credential $cred
Select-AzureSubscription -Current 'SubscriptionName'
Get-AzureVM | Stop-AzureVM –Force
Get-AzureRmVM | Stop-AzureRmVM -Force
}
AzureResourceManager モジュールを Azure Automation アカウントにインポートしました。
しかし、私はこのエラーが発生しています:
Exception
At line:34 char:2
+ Get-AzureRMVM | Stop-AzureRMVM -Force
+ ~~~~~~~~~~~~~ Cannot find the 'Get-AzureRMVM' command. If this command is defined as a workflow, ensure it is defined before the workflow that calls it. If it is a command intended to run directly within Windows PowerShell (or is not available on this system), place it in an InlineScript: 'InlineScript { Get-AzureRMVM }'
そんなことがあるものか ?
編集:以下は解決策です
$cred = Get-AutomationPSCredential -Name 'Cred'
Add-AzureRmAccount -Credential $cred
Select-AzureRmSubscription -Name 'SubscriptionName' -SubscipritionId 'SubscriptionId'
Get-AzureRmVM | Stop-AzureRmVM -Force
私が見つけたすべてのワークフローは、標準の Add-AzureAccount と Select-AzureSubscription の代わりに、Add-AzureRmAccount と Select-AzureRmSubcription の使用について言及していませんでした。Azure アカウントへの認証プロセスは同じだと思いました。
更新 : 同じ Runbook 内で ASM と ARM コマンドレットの両方を組み合わせることができるようになりました。Azure Automation で既定でサポートされている ARMの詳細については、この投稿を参照してください。