Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在C中停用和激活Azure WebJobs#_C#_Azure_Azure Web App Service_Web Deployment_Azure Webjobs - Fatal编程技术网

C# 在C中停用和激活Azure WebJobs#

C# 在C中停用和激活Azure WebJobs#,c#,azure,azure-web-app-service,web-deployment,azure-webjobs,C#,Azure,Azure Web App Service,Web Deployment,Azure Webjobs,我有一个问题,我想在部署新版本时停用appservice的webjobs,并在再次部署后激活它们 在c#中有这样做的可能性吗 谢谢大家要从外部客户端停止WebJob,只需拨打REST电话: 这将添加一个disabled.job文件 重新启动WebJob POST https://{sitename}.scm.azurewebsites.net/api/continuouswebjobs/{job name}/start 这将删除禁用的作业文件,webjob将再次运行要从外部客户端停止we

我有一个问题,我想在部署新版本时停用appservice的webjobs,并在再次部署后激活它们

在c#中有这样做的可能性吗


谢谢大家

要从外部客户端停止WebJob,只需拨打REST电话:

这将添加一个disabled.job文件

重新启动WebJob

   POST https://{sitename}.scm.azurewebsites.net/api/continuouswebjobs/{job name}/start

这将删除禁用的作业文件,webjob将再次运行

要从外部客户端停止webjob,您只需进行REST调用:

这将添加一个disabled.job文件

重新启动WebJob

   POST https://{sitename}.scm.azurewebsites.net/api/continuouswebjobs/{job name}/start

这将删除已禁用的作业文件,webjob将再次运行

正如我所知,您无法直接停止已触发的webjob,您需要利用process explorer通过来终止它。对于连续的WebJobs,您可以利用启动/停止WebJobs,您需要使用web应用程序的基本auth调用特定的restapi。下面是停止WebJob的c#代码片段:

string username = "{username}";
string password = "{password}";
string jobname = "{your-webjob-name}";
string authorization = Convert.ToBase64String(System.Text.UTF8Encoding.UTF8.GetBytes($"{username}:{password}"));
using (var client = new HttpClient())
{
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authorization);
    var res = await client.PostAsync($"https://{your-webapp-name}.scm.azurewebsites.net/api/continuouswebjobs/{jobname}/stop", null);
    Console.WriteLine($"StatusCode:{res.StatusCode}");
}
注意:此时,名为
disable.job
的文件将与您的WebJob一起添加,如下所示:


要启动WebJob,只需调用
/api/continuouswebjobs/{job name}/start
,然后
禁用.job
文件将被删除,WebJob将再次运行

正如我所知,您无法直接停止触发的WebJob,您需要利用process explorer通过。对于连续的WebJobs,您可以利用启动/停止WebJobs,您需要使用web应用程序的基本auth调用特定的restapi。下面是停止WebJob的c#代码片段:

string username = "{username}";
string password = "{password}";
string jobname = "{your-webjob-name}";
string authorization = Convert.ToBase64String(System.Text.UTF8Encoding.UTF8.GetBytes($"{username}:{password}"));
using (var client = new HttpClient())
{
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authorization);
    var res = await client.PostAsync($"https://{your-webapp-name}.scm.azurewebsites.net/api/continuouswebjobs/{jobname}/stop", null);
    Console.WriteLine($"StatusCode:{res.StatusCode}");
}
注意:此时,名为
disable.job
的文件将与您的WebJob一起添加,如下所示:

要启动WebJob,只需调用
/api/continuouswebjobs/{job name}/start
,然后
禁用.job
文件将被删除,WebJob将再次运行

在web服务上进行良好的呼叫(双关语)以停止WebJob。但是,为了再次启动WebJob,您所指的是什么文件呢?在web服务上打个好电话(双关语)来停止WebJob。但是,为了再次启动WebJob,您指的是什么文件?