我有两个预定的作业,每个作业都运行自己的控制台应用程序(.exe)
我更新了可执行文件的代码,现在我想将它们部署到Azure。在过去,我删除了旧的工作,并从头开始重新发布新的工作。
但我想知道有没有办法更新代码而无需重新创建作业和设置?
答案 0 :(得分:0)
你可以使用createorUpdate api来更新你的工作,这里是示例代码
public async Task CreateOrUpdateJobAsync(string jobCollectionName, string jobId, DateTime startDate, string recurrence, CancellationToken cancellationToken)
{
var schedulerClient = new SchedulerClient(this.cloudServiceName, jobCollectionName, this.credentials);
var job = new JobCreateOrUpdateParameters()
{
Action = new JobAction()
{
Type = JobActionType.Https,
Request = new JobHttpRequest()
{
Body = "",
Headers = new Dictionary<string, string>()
{
{ "Content-Type", "application/x-www-form-urlencoded" },
{ "x-something", "value123" }
},
Method = "POST",
Uri = new Uri(""),
Authentication = new AADOAuthAuthentication()
{
Type = HttpAuthenticationType.ActiveDirectoryOAuth,
Tenant = "",
ClientId = "",
Audience = "",
Secret = ""
}
}
},
StartTime = startDate,
Recurrence = new JobRecurrence()
{
Frequency = JobRecurrenceFrequency.Minute,
Interval = 1
}
};
var result = await schedulerClient.Jobs.CreateOrUpdateAsync(jobId, job, cancellationToken);
}