我可以从 Azure 网站调用 Azure webjob 并传递参数吗? [英] Can I invoke an Azure webjob from an Azure website and pass it parameters?

查看:18
本文介绍了我可以从 Azure 网站调用 Azure webjob 并传递参数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个想从 Azure 网站调用的 Azure Web 作业.我想将字符串参数从网站传递到网络作业.

I have an Azure webjob that I want to invoke from an Azure website. I want to pass string parameters from the website to the webjob.

我知道我可以将网络作业作为 REST API 调用(https://github.com/projectkudu/kudu/wiki/网络工作).
所以我可以在没有任何参数的情况下调用 webjob:POST jobs/triggered/myjobname/run

I know I can invoke the webjob as a REST API (https://github.com/projectkudu/kudu/wiki/Web-jobs).
So I can invoke the webjob without any parameters: POST jobs/triggered/myjobname/run

但在最后添加参数似乎不起作用,即 jobs/triggered/myjobname/run?myparam1=value1

But adding parameters at the end doesn't appear to be working, i.e. jobs/triggered/myjobname/run?myparam1=value1

我看到的关于在 Microsoft.WindowsAzure.Jobs 中使用属性进行绑定的信息没有提到我的情况,只是绑定到 Azure 存储项(http://blogs.msdn.com/b/jmstall/archive/2014/01/28/trigger-azurejobs.aspx 中的绑定和路由参数).

The information I see on using attributes in Microsoft.WindowsAzure.Jobs for binding doesn't mention my case, just binding to Azure storage items (http://blogs.msdn.com/b/jmstall/archive/2014/01/28/trigger-bindings-and-route-parameters-in-azurejobs.aspx).

我想做的事情可行吗?我是否需要在 Azure 存储队列中创建一个新项目来触发我的网络作业?

Is what I want to do doable? Do I need to do something like create a new item in an Azure storage queue to trigger my webjob?

谢谢.

推荐答案

如果你想从你的网站调用一个 WebJob,你能做的最好的事情就是在你的网站中包含 WebJob 代码并调用该代码,你仍然可以从您的网站内部轻松使用 WebJob SDK.(用于调用 WebJobs SDK 方法示例:https://web.archive.org/web/20180415074357/http://thenextdoorgeek.com/post/WAWS-WebJob-to-upload-FREB-files-to-Azure-Storage-using-the-WebJobs-SDK).

If you want to invoke a WebJob from your Website, the best thing you can do is simply have the WebJob code inside your Website and simply call that code, you can still easily use the WebJob SDK from inside your Website. (for calling a WebJobs SDK method sample: https://web.archive.org/web/20180415074357/http://thenextdoorgeek.com/post/WAWS-WebJob-to-upload-FREB-files-to-Azure-Storage-using-the-WebJobs-SDK).

您不想从您的网站调用 WebJob 的原因是该调用包含一个您不想存储在您的网站上的秘密(部署凭据).

The reason you wouldn't want to invoke the WebJob from your Website is that the invocation contains a secret you rather not store on your Website (deployment credentials).

如果您宁愿将 WebJob 和网站代码分开,最好的做法是使用队列进行通信,WebJob 侦听队列,网站将请求推送到队列.

If you rather separate WebJob and Website code, the best thing to do is to communicate using a queue, the WebJob listens on the queue and the Website pushes the request to the queue.

关于原问题,目前没有办法将参数传递给WebJob调用调用.

Regarding the original question, currently there is no way to pass parameters to the WebJob invoke call.

这篇关于我可以从 Azure 网站调用 Azure webjob 并传递参数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆