Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/277.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# 从代码运行触发的Azure WebJob_C#_Azure_Azure Webjobs - Fatal编程技术网

C# 从代码运行触发的Azure WebJob

C# 从代码运行触发的Azure WebJob,c#,azure,azure-webjobs,C#,Azure,Azure Webjobs,我创建了一个控制台应用程序上载为Azure trigger Webjob。当我从Azure门户运行它时,它工作正常。我想用我的C代码运行这个。我不想使用队列或服务总线。我只想在用户在我的web应用程序中执行特定操作时触发它 搜索之后,我得到了一个解决方案,可以从计划的 知道如何从代码运行吗 您可以通过WebJob API触发WebJob。C#代码包含在以下帖子中: 正如Justin所说,我们可以使用WebJobAPI来实现这个需求。我们可以在以下位置找到此KUDU API:。下面是我的测试代

我创建了一个控制台应用程序上载为Azure trigger Webjob。当我从Azure门户运行它时,它工作正常。我想用我的C代码运行这个。我不想使用队列或服务总线。我只想在用户在我的web应用程序中执行特定操作时触发它

搜索之后,我得到了一个解决方案,可以从计划的


知道如何从代码运行吗

您可以通过WebJob API触发WebJob。C#代码包含在以下帖子中:


正如Justin所说,我们可以使用WebJobAPI来实现这个需求。我们可以在以下位置找到此KUDU API:。下面是我的测试代码:

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://<web appname>.scm.azurewebsites.net/api/triggeredwebjobs/<web job name>/run");
request.Method = "POST";
var byteArray = Encoding.ASCII.GetBytes("user:password"); //we could find user name and password in Azure web app publish profile 
request.Headers.Add("Authorization", "Basic "+ Convert.ToBase64String(byteArray));            
request.ContentLength = 0;
try
{
    var response = (HttpWebResponse)request.GetResponse();
}
catch (Exception e) {

}
HttpWebRequest请求=(HttpWebRequest)HttpWebRequest.Create(“https://.scm.azurewebsites.net/api/triggeredwebjobs//run");
request.Method=“POST”;
var byteArray=Encoding.ASCII.GetBytes(“用户:密码”)//我们可以在Azure web app发布配置文件中找到用户名和密码
request.Headers.Add(“Authorization”,“Basic”+Convert.ToBase64String(byteArray));
request.ContentLength=0;
尝试
{
var response=(HttpWebResponse)request.GetResponse();
}
捕获(例外e){
}

这对我来说很有效。希望能有所帮助。

谢谢,这很有效。有没有办法检查web作业何时完成,因为我必须通知用户这一点?
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://<web appname>.scm.azurewebsites.net/api/triggeredwebjobs/<web job name>/run");
request.Method = "POST";
var byteArray = Encoding.ASCII.GetBytes("user:password"); //we could find user name and password in Azure web app publish profile 
request.Headers.Add("Authorization", "Basic "+ Convert.ToBase64String(byteArray));            
request.ContentLength = 0;
try
{
    var response = (HttpWebResponse)request.GetResponse();
}
catch (Exception e) {

}