Completion of device setup for Azure StorSimple Virtual Device Fails in Automation Runbooks

259 views Asked by At

I am creating an Azure Storsimple virtual device and a storage container in it using Runbook automation. After creation of the device I need to Complete the Device setup ie (setting up Snapshot manager password,Administrator password and service encryption key).

$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"
}  

This code works perfectly fine if I run in my powershell. But if I run it in Automation runbook then the device gets created but the configuration step alone fails.

0

There are 0 answers