我有两个计划的作业,每个作业都运行自己的控制台应用程序 (.exe)
我更新了可执行文件的代码,现在我想将它们部署到 Azure。过去,我删除了旧作业并从头开始重新发布新作业。
但我想知道有没有办法更新代码而不必重新创建作业和设置?
我有两个计划的作业,每个作业都运行自己的控制台应用程序 (.exe)
我更新了可执行文件的代码,现在我想将它们部署到 Azure。过去,我删除了旧作业并从头开始重新发布新作业。
但我想知道有没有办法更新代码而不必重新创建作业和设置?
您可以使用 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);
}