如何通过VSTS PowerShell脚本在Azure中禁用或停止并启用计划程序作业? [英] How to disable or stop and enable the scheduler Jobs in Azure from VSTS PowerShell scripts?

查看:81
本文介绍了如何通过VSTS PowerShell脚本在Azure中禁用或停止并启用计划程序作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PFA 6 PFA 3 PFA PFA 5 我有一些已触发的作业正在Azure中运行.我已经为Azure中的那些作业创建了计划程序作业,以便每当我禁用它时,它将停止运行已触发的作业,而不是杀死它们.但是我想使用插件或Powershell脚本从VSTS禁用那些计划程序作业.我可以使用Powershell脚本停止和启动连续Web作业,但是触发了作业/调度程序作业,我不确定如何从VSTS定义中禁用Powershell/插件/任务.

PFA 6 PFA 2 PFA 3 PFA PFA 4 PFA 5 I have some triggered jobs running in Azure. I have created scheduler jobs for those jobs in Azure so that whenever I disable it will stop running the triggered jobs instead of killing. But I want to disable those scheduler jobs from VSTS using plugin or Powershell script. I can stop and start Continuous webjobs using Powershell scripts but triggered jobs/scheduler jobs I am not sure how to disable using Powershell/Plugins/Tasks from VSTS definitions.

推荐答案

您可以添加Azure Powershell脚本任务并在下面添加脚本以启用/禁用调度程序作业:

You can add an Azure Powershell Script Task and add the script below to Enable/Disable the scheduler jobs:

将作业设置为已禁用":

Set the Job to "Disabled":

Set-AzureRmSchedulerHttpJob -ResourceGroupName ABC -JobCollectionName ABC -JobName ABC -JobState Disabled

将作业设置为已启用":

Set the Job to "Enabled":

Set-AzureRmSchedulerHttpJob -ResourceGroupName ABC -JobCollectionName ABC -JobName ABC -JobState Enabled

如果要启用/禁用JobCollection,可以使用Enable-AzureRmSchedulerJobCollectionDisable-AzureRmSchedulerJobCollection命令:

If you want to enable/disable the JobCollection, you can use Enable-AzureRmSchedulerJobCollection and Disable-AzureRmSchedulerJobCollection Command:

Enable-AzureRmSchedulerJobCollection -ResourceGroupName ABC -JobCollectionName ABC

使用以下脚本:

$JobC = Get-AzureRmSchedulerJobCollection -ResourceGroupName jobcollection -JobCollectionName jobcollection

If ($JobC.State -eq "Enabled")
{
    Write-Host "JobCollection is enabled, disabling it..."
    Disable-AzureRmSchedulerJobCollection -ResourceGroupName jobcollection -JobCollectionName jobcollection
    Write-Host "JobCollection is disabled now."
}
Else
{
    Write-Host "JobCollection has already been disabled."
}

这篇关于如何通过VSTS PowerShell脚本在Azure中禁用或停止并启用计划程序作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆