2016-11-01 7 views
0

Ich möchte ein Runbook nach einem Zeitplan ausgeführt haben, aber beenden, wenn der letzte Job nicht beendet ist (dh wenn der Zeitplan alle 2 Stunden und ein Job 2,5 Stunden und dann der nächste Job dauert sollte nicht laufen).Job-Status in Azure Runbook

Ich habe versucht, Get-AzureAutomationJob zu verwenden, um den letzten Jobstatus zu erhalten (https://azure.microsoft.com/en-gb/documentation/articles/automation-runbook-execution/#retrieving-job-status-using-windows-powershell), aber ich kann es nicht zum Laufen bringen. Ich nehme an, dass die ganze Präambel, um das Abonnement usw. zu bekommen, erforderlich ist.

"Get-AzureAutomationJob: Das Automatisierungskonto wurde nicht gefunden."

$ConnectionAssetName = "AzureClassicRunAsConnection" 

# Get the connection 
$connection = Get-AutomationConnection -Name $connectionAssetName   

# Authenticate to Azure with certificate 
Write-Verbose "Get connection asset: $ConnectionAssetName" -Verbose 
$Conn = Get-AutomationConnection -Name $ConnectionAssetName 
if ($Conn -eq $null) 
{ 
    throw "Could not retrieve connection asset: $ConnectionAssetName. Assure   that this asset exists in the Automation account." 
} 

$CertificateAssetName = $Conn.CertificateAssetName 
Write-Verbose "Getting the certificate: $CertificateAssetName" -Verbose 
$AzureCert = Get-AutomationCertificate -Name $CertificateAssetName 
if ($AzureCert -eq $null) 
{ 
    throw "Could not retrieve certificate asset: $CertificateAssetName.  Assure that this asset exists in the Automation account." 
} 

Write-Verbose "Authenticating to Azure with certificate." -Verbose 
Set-AzureSubscription -SubscriptionName $Conn.SubscriptionName -  SubscriptionId $Conn.SubscriptionID -Certificate $AzureCert 
Select-AzureSubscription -SubscriptionId $Conn.SubscriptionID 

$job = (Get-AzureAutomationJob –AutomationAccountName "THE NAME OF THE AUTOMATION ACCOUNT AS IT APPEARS IN THE PORTAL" –Name "JobStatusTest" | sort LastModifiedDate –desc)[0] 

Antwort

0

Nun, Sie müssten Get-AzureRMAutomation Job dafür verwenden. Lassen Sie mich das näher ausführen, ich denke, im März 2016 hat Microsoft Azure Automation vom OLD azure Modell entfernt und jetzt ist es nur im neuen vorhanden. also müssten Sie RM zu Ihren Commandlets hinzufügen

+0

Danke. Ich habe das versucht, aber ich bekomme den gleichen Fehler; "Get-AzureRmAutomationJob: Das Automatisierungskonto wurde nicht gefunden" – SturmUndDrang

+0

nun, dann müssen Sie nur die Rechtschreibung überprüfen, das könnte der Trick sein? Außerdem sollten Sie den Switch -ResourceGroup und den Switch für die Ressourcengruppe angeben – 4c74356b41

Verwandte Themen