powershellazureazure-schedulerazure-runbook

How can I delete Azure Jobs by Azure Runbook?


I'm writing one Azure Runbook that must clean montly my test environment.

I need delete some Azure Jobs but when I try to retrieve my jobs with Get-AzureRmSchedulerJob command I obtain this error:

Get-AzureRmSchedulerJob -ResourceGroupName MyResourceGroupName -JobCollectionName myJobCollectionName

Get-AzureRmSchedulerJob : The term 'Get-AzureRmSchedulerJob' is not recognized as the name of a cmdlet, function, 

script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is 

correct and try again.

At line:10 char:1

+ Get-AzureRmSchedulerJob -ResourceGroupName MyResourceGroupName

+ ~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (Get-AzureRmSchedulerJob:String) [], CommandNotFoundException

    + FullyQualifiedErrorId : CommandNotFoundException

How can I retrieve my jobs inside Azure Runbook? Using PowerShell this command works. I need cycle all jobs because I cannot delete all jobs.

Thanks


Solution

  • How can I retrieve my jobs inside Azure Runbook? Using PowerShell this command works. I need cycle all jobs because I cannot delete all jobs.

    Powershell command Get-AzureRmSchedulerJob is in the AzureRM.Scheduler. According to exception The term 'Get-AzureRmSchedulerJob' is not recognized as the name of a cmdlet, function, I assume that there is no AzureRM.Scheduler in your automation account modules.

    By default, it is not in Automation. You could check it from azure portal.

    Note: Dependencies: AzureRM.Profile (≥ 4.0.0). If AzureRM.Profile (<4.0.0) you need to update the AzureRM.Profile before import AzureRM.Scheduler

    enter image description here

    If it is not in the modules. We could install it manually.

    enter image description here enter image description here