2016-05-08 50 views
0

我有兩個計劃任務,每個都運行自己的控制檯應用程序(.exe)如何更新預定作業?

我更新了可執行文件的代碼,現在我想將它們部署到Azure。在過去,我刪除了舊的工作,並重新發布了新的工作。

但我想知道有沒有辦法更新代碼而無需重新創建作業和設置?

回答

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); 
      }