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]
Danke. Ich habe das versucht, aber ich bekomme den gleichen Fehler; "Get-AzureRmAutomationJob: Das Automatisierungskonto wurde nicht gefunden" – SturmUndDrang
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