AzureでWindows VMでPSRemotingを有効にしようとしました。先週からそれはしばらく働いていたが、スクリプトはこれ以上働かなかった。Azure VMでスクリプトを実行
私はカスタムスクリプト拡張機能を使用してスクリプトを実行しました:
Set-AzureRmVMCustomScriptExtension -ResourceGroupName $ResourceGroupName -VMName $VMName -Name "EnableWinRM_HTTP0" -Location $vm.Location -StorageAccountName $storageaccountname -StorageAccountKey $key -FileName "ConfigureWinRM_HTTP1.ps1" -ContainerName "scripts" -RunFile "ConfigureWinRM_HTTP1.ps1"
ConfigureWinRM_HTTP1.ps1
スクリプトは以下の通りである:
# Ensure PS remoting is enabled, although this is enabled by default for Azure VMs
Enable-PSRemoting -Force
# Create rule in Windows Firewall
New-NetFirewallRule -Name "WinRM HTTP" -DisplayName "WinRM HTTP" -Enabled True -Profile Any -Action Allow -Direction Inbound -LocalPort 5985 -Protocol TCP
# Run WinRM configuration on command line.
$cmd = "winrm create winrm/config/Listener?Address=*+Transport=HTTP"
cmd.exe /C $cmd
仮想マシンが正常にいくつかの行の前に同じスクリプトで作成されますが、このスクリプトが実行されると、次のエラーが表示されます。
Set-AzureRmVMCustomScriptExtension : Long running operation failed with status 'Failed'. Additional Info:'VM has
reported a failure when processing extension 'EnableWinRM_HTTP0'. Error message: "Finished executing command".'
ErrorCode: VMExtensionProvisioningError
ErrorMessage: VM has reported a failure when processing extension 'EnableWinRM_HTTP0'. Error message: "Finished
executing command".
StartTime: 29/11/2017 15:07:24
EndTime: 29/11/2017 15:08:14
OperationID: aa418b4a-76b4-4482-93eb-16b734009388
Status: Failed
At C:\.....\SetupVM.ps1:107 char:2
+ Set-AzureRmVMCustomScriptExtension -ResourceGroupName $ResourceGr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzureRmVMCustomScriptExtension], ComputeCloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.SetAzureVMCustomScriptExtensionCommand
Azure管理ポータルのモニタに、同じエラーメッセージ以外の何も表示されません。
なぜ機能しないのですか?
を使用すると、カスタムスクリプト拡張を使用してVM上でスクリプトを実行している場合、あなたは時々、VMが正常に作成されたが、スクリプトが失敗したエラーに遭遇する可能性があります。これらの条件の下で、このエラーから回復するには、拡張を削除してテンプレートを再実行することをお勧めします。注:将来、この機能が拡張され、拡張機能のアンインストールが不要になります。 –
だから、リトライロジックのようなものを実装しなければなりませんでしたか?試行の間にいくらか遅れを取る方が良いですか? –
'' 'C:\ WindowsAzure \ Logs \ Plugins \ Microsoft.Compute.CustomScriptExtension'''でログファイルを調べてみてください。うまくいけば、エラーの詳細が表示されます。 –