在Automation Runbooks中完成Azure StorSimple虚拟设备的设备设置失败

时间:2015-06-22 19:01:49

标签: powershell azure azure-powershell azure-automation

我正在使用Runbook自动化创建Azure Storsimple虚拟设备和存储容器。创建设备后,我需要完成设备设置,即(设置快照管理器密码,管理员密码和服务加密密钥)。

$NewDeviceJob=New-AzureStorSimpleVirtualDevice -VirtualDeviceName $VirtualDeviceName -VirtualNetworkName $VirtualNetworkName -StorageAccountName  $StorageAccount -SubNetName $SubNetName 

#waiting for storsimple device creation
$loopvariable=$true 
while($loopvariable -eq $true)
{
    Start-Sleep -s 10
    $DeviceCreationOutput=Get-AzureStorSimpleJob -InstanceId ($NewDeviceJob.ToString())
    if($DeviceCreationOutput.Status -ne "Running"){
        $loopvariable=$false 
    }


}

$status=$DeviceCreationOutput.Status

if($Status -ne "Completed")
{
    Write-Output "Virtual Appliance Creation $Status "
    Exit
}

Write-Output "Virtual Device Created "

#waitforthe Device To get Online

$loopvariable=$true
while($loopvariable -eq $true){
   Start-Sleep -s 5
   $VirtualDevice=  Get-AzureStorSimpleDevice -DeviceName $VirtualDeviceName
   if($VirtualDevice.Status -eq "Online"){
        $loopVariable=$false
    }
 } 

Start-Sleep -s 10
 $configoutput=Set-AzureStorSimpleVirtualDevice -DeviceName $VirtualDeviceName -SecretKey $VDServiceEncryptionKey -AdministratorPassword $VDDeviceAdministratorPassword -SnapshotManagerPassword $VDSnapShotManagerPassword
if($configoutput.TaskStatus -eq "Completed"){
    Write-Output "Configuration of Virtual Device Successful"
}
else
{
Write-Output "configuration of virtual device failed"
}  

如果我在PowerShell中运行,这段代码可以正常工作。但是如果我在Automation Runbook中运行它,那么设备就会被创建,但仅配置步骤就会失败。

0 个答案:

没有答案