shimon893
shimon893

Reputation: 317

runbook Start-AzureRMVM works but never ends

I have strange problem, while doing tutorials for starting VM from automation: https://learn.microsoft.com/en-us/azure/automation/automation-first-runbook-textual

My code is exactly like in first step, and it authenticates corretly:

workflow MyFirstRunbook-Workflow
    {
    $Conn = Get-AutomationConnection -Name AzureRunAsConnection
    Add-AzureRMAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint
    Start-AzureRmVM -Name 'VMName' -ResourceGroupName 'ResourceGroupName'
    }

Even when I check, VM starts, but runbook never ends. It just says: "Running...." (more dots are appending all the time). Any idea why is this happening? As it clearly works, but for some reason cannot end. And I think all settings are like in tutorial... It is Powershell Workflow runbook.

Upvotes: 2

Views: 1122

Answers (1)

Jason Ye
Jason Ye

Reputation: 13954

To troubleshoot this issue more efficiently, we should do some test.
1.Use PowerShell to get the job status, script like this:

PS C:\windows\system32> Login-AzureRmAccount
PS C:\windows\system32> Get-AzureRmAutomationJob -Id '29caa9f3-1862-4710-b1d3-c98c1841966f' -ResourceGroupName 'vm' -AutomationAccountName 'jasonrunbook' | select status

Status
------
Completed

2.Please test this PowerShell workflow runbook:

workflow jasontest2
{

    $Conn = Get-AutomationConnection -Name AzureRunAsConnection
    Add-AzureRMAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint
    $a = get-azurermvm -Name 'vmname' -ResourceGroupName 'rg'
    write-output $a
    Start-AzureRmVM -Name 'vmname' -ResourceGroupName 'rg'
    write-output "ok"

}

Then find the result in Output, if it still show running, please post the screenshot here.

Upvotes: 2

Related Questions