创建PowerShell中预定的Azure WebJob

编程入门 行业动态 更新时间:2024-10-20 08:28:59
本文介绍了创建PowerShell中预定的Azure WebJob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想创建一个Azure的WebJob发送 BrokeredMessage 到Azure的ServiceBus主题,创建和发送邮件的实际行为是微不足道的,但是我已经无力找到一种方法来自动调度WebJob的创建。

I am trying to create an Azure WebJob to send a BrokeredMessage to an Azure ServiceBus Topic, the actual act of creating and sending the message is trivial however I have been unable to find a way to automate the creation of the Scheduled WebJob.

在自动化的工作流程应该工作如下:

The automated workflow should work as follows:

  • 创建一个新的Azure网站的 [完成]
  • 创建一个新的Azure触发上传WebJob一个PS1文件的 [完成]
  • 创建一个新的Azure调度作业收集的 [证明的概念]
  • 创建一个新的Azure调度工作触发WebJob
  • 在Azure管理门户提供了此功能的漂亮的UI,它在幕后在选定的网站创建的Azure WebJob,湛蓝的调度作业收集和Azure的调度工作:

    The Azure Management Portal provides a nice UI for this functionality, which under the covers creates an Azure WebJob in the selected WebSite, an Azure Scheduler Job Collection and an Azure Scheduler Job:

    有没有出现是创建与天青服务管理的PowerShell模块调度天青WebJob类似的机制。这当然是可以创建新的 WebJobs ,的Azure调度集合和乔布斯 - 但是我不知道在Azure计划程序发布到调度Azure的WebJobs什么URL或存储队列

    There doesn't appear to be an analogous mechanism for creating a scheduled Azure WebJob with the Azure Service Management PowerShell Module. It is certainly possible to create new WebJobs, Azure Scheduler Collections and Jobs - however I have no idea what URL or Storage Queue the Azure Scheduler is posting to to schedule Azure WebJobs.

    推荐答案

    有天青是Scheduler和天​​青WebJobs之间有着密切的关系。具体的Azure WebJobs不具有任何安排内部支持,WebJobs依赖于天青调度打电话到 *。scm.azurewebsites 网​​站。

    There is a close relationship between Azure Scheduler and Azure WebJobs. Specifically Azure WebJobs does not have any internal support for scheduling, WebJobs relies on the Azure Scheduler to call into the *.scm.azurewebsites website.

    因此​​,它有可能使用PowerShell命令对这些服务设置天青WebJobs要使用天青调度时间表触发

    As such it is possible to use PowerShell cmdlets for these services to setup Azure WebJobs to be triggered on schedule using Azure Scheduler.

    $location = "North Europe"; $site = New-AzureWebsite -Location $location ` -Name "amido-test-website"; $job = New-AzureWebsiteJob -Name $site.Name ` -JobName "amido-test-job" ` -JobType Triggered ` -JobFile ~\Desktop\test.zip; $jobCollection = New-AzureSchedulerJobCollection ` -Location $location ` -JobCollectionName "amido-test-job-collection"; $authPair = "$($site.PublishingUsername):$($site.PublishingPassword)"; $pairBytes = [System.Text.Encoding]::UTF8.GetBytes($authPair); $encodedPair = [System.Convert]::ToBase64String($pairBytes); New-AzureSchedulerHttpJob ` -JobCollectionName $jobCollection[0].JobCollectionName ` -JobName "test" ` -Method POST ` -URI "$($job.Url)\run" ` -Location $location ` -StartTime "2014-01-01" ` -Interval 1 ` -Frequency Minute ` -EndTime "2015-01-01" ` -Headers @{ ` "Content-Type" = "text/plain"; ` "Authorization" = "Basic $encodedPair"; ` };

    这是一个有点长用简单的英语上面的脚本啰嗦这么执行以下操作:

    It's a little long winded so in plain english the above script does the following:

  • 创建一个新的Azure网站。
  • 创建和上传新WebJob。
  • 创建一个新的Azure调度作业集合。
  • 生成HTTP基本身份验证标头值。
  • 创建一个新的Azure调度HTTP工作,使经过身份验证的请求* .scm.azurewebsites API。
  • 希望这会刮伤他们的头试图找出这一个节省一些其他开发人员。

    Hope this saves a few other developers from scratching their head trying to figure this one out.

    更多推荐

    创建PowerShell中预定的Azure WebJob

    本文发布于:2023-11-14 04:26:15,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1586214.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:PowerShell   Azure   WebJob

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!