如何防止 Azure webjobs 在 Azure 网站生产中被交换<-->暂存槽 [英] How to prevent Azure webjobs from being swapped in Azure website production <--> staging slots

查看:18
本文介绍了如何防止 Azure webjobs 在 Azure 网站生产中被交换<-->暂存槽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有多个实例的生产和暂存槽的 Azure 网站.

I have an Azure website with a production and staging slot with multiple instances.

我在网站上运行了几个 Azure webjobs,其中一些是连续触发的.

I run several Azure webjobs on the site, some of which are triggered others that are continuous.

我了解触发的网络作业只会在一个实例上运行一次.

I understand triggered webjobs will only run once on one instance.

我目前的设置是:

  • 生产站点除了从登台交换之外没有部署

  • Production site has no deployment other than swapping from staging

Staging 网站已设置为从 bitbucket 持续部署

Staging website is setup to continuous deployment from bitbucket

使用发布到 Azure"将 Web 作业从 VS 内部署到生产槽(因为 AFAIK 不支持基于计划的 Web 作业的持续部署)

Webjobs are deployed from within VS to production slot using "publish to Azure" (since AFAIK there is no support for continuous deployment of webjobs that are schedule based)

网站的VS解决方案与包含webjobs的VS解决方案不同

The VS solution for the website is different from the VS solution containing webjobs

我注意到当我交换生产和登台时,webjobs 也被交换了!当我将一个新的 webjob 部署到生产环境并随后进行了网站部署和交换时,我意识到了这一点,新部署的 webjob 不再在生产槽中!

I noticed when I swap production and staging, webjobs are also swapped! I realized this when I had deployed a new webjob to production and subsequently did a website deployment followed by a swap, the newly deployed webjob was no longer in the production slot!

我的问题:

  1. 是否可以防止 webjobs 在生产和登台之间交换(webjobs 与网站实际上是完全不同的代码片段)

  1. is it possible to prevent webjobs from swapping between production and staging (webjobs are really entirely different pieces of code than the website)

究竟是什么换成了网络作业?二进制文件?日程?两者都有?

What exactly is swapped for webjobs? Binaries? Schedule? Both ?

如何防止所有 webjobs 在暂存槽上运行?我的网络作业不需要高度可用,我可以轻松地离线测试它们.

how do i prevent all webjobs from running on the staging slot? My webjobs do not need to be highly available and i can test them offline easily.

如果我 VS 将 webjobs 部署到暂存槽并进行交换,那么当前的暂存槽将丢失已部署的 webjob,当我进行下一次网站更新时我会丢失它,所以我应该在哪里部署我的网络作业?

If i VS deploy webjobs to the staging slot and do a swap, then the current staging slot will be missing the deployed webjob and I'll lose it when i do my next website update, so where should i be deploying my webjobs?

有一个 相关线程,但它假设 webjob 与这不是我目前拥有的网站.

There is a related thread but it assumes the webjob is deployed simultaneously with a website which is not what I have currently.

我真的很喜欢网站和 webjobs,但是关于 webjobs 和网站持续独立部署的故事似乎被打破了.

I really like websites and webjobs, but it seems the story related to continuous independent deployment of webjobs and websites is broken.

非常感谢您的建议!

谢谢

推荐答案

Azure 网站部署槽不是一个容易理解的概念,再加上 WebJobs 就有点困难了.

Azure websites deployment slots are not an easy concept to understand, together with WebJobs it gets a little bit more difficult.

我建议阅读以下帖子以更好地了解部署槽 - http://blog.amitapple.com/post/2014/11/azure-websites-slots/(包括有用信息的评论部分)

I suggest reading the following post to get a better understanding on deployment slots - http://blog.amitapple.com/post/2014/11/azure-websites-slots/ (including the comments section for useful information)

要更好地了解 WebJobs 如何工作和部署,请参阅这篇文章 - http://blog.amitapple.com/post/74215124623/deploy-azure-webjobs/

To get a better understanding on how WebJobs work and deployed see this post - http://blog.amitapple.com/post/74215124623/deploy-azure-webjobs/

理解这一点很重要:

  1. 在交换部署槽时,您实际上是在两个槽之间交换网站的内容/文件.
  2. WebJobs 是网站内容的一部分.

因此,当您交换插槽时,您实际上交换了包括 WebJob 在内的网站文件.

So when you swap the slot you actually swap the website files including the WebJob.

请注意,直接部署 WebJob 而不是作为网站文件/存储库的一部分是一种不好的做法,这可能是您遇到问题的原因.

Note it is a bad practice to deploy a WebJob directly and not as part of your website files/repository, this is probably the cause of issues you are having.

要防止 WebJobs 在暂存槽上运行,您可以添加一个名为 WEBJOBS_STOPPED 的应用设置并将其设置为 1(在 azure 门户中).(来源).确保此应用设置粘在槽上,否则它会传播到生产槽.

To prevent WebJobs from running on the staging slot you can add an app setting called WEBJOBS_STOPPED and set it to 1 (in the azure portal). (source). Make sure this app setting is sticky to the slot otherwise it'll propagate to the production slot.

这篇关于如何防止 Azure webjobs 在 Azure 网站生产中被交换<-->暂存槽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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