标签: azure-webjobs

在“停止”模式下部署 azure webjob

我在 Azure 门户中的暂存槽中使用自动部署来部署 Webjob,但问题是此 webjob 在部署后直接运行,它可能会导致主槽 webjob 和暂存 webjob 之间出现混淆。

有没有办法在不运行 webjob 的情况下部署它,除非我启动它并交换插槽?

azure-deployment azure-webjobs

5
推荐指数
0
解决办法
406
查看次数

为什么 Azure WebJob ServiceBus 默认反序列化 XML?

我有一个简单的 Azure WebJobs ServiceBusTrigger,看起来像

public static async void ProcessQueueMessage([ServiceBusTrigger("myqueuename")] String json, TextWriter log) { ... }
Run Code Online (Sandbox Code Playgroud)

不幸的是,它无法将 JSON 反序列化为 XML(不足为奇)。我检查了有效负载并确认它只是一个 UTF-8 编码的字节数组。我有两个问题。

  1. 为什么假设我的 String 是 XML?
  2. 我怎么告诉它不,没有 XML,只有一个字符串?

堆栈跟踪:

System.InvalidOperationException: Exception binding parameter 'json' ---> System.Runtime.Serialization.SerializationException: There was an error deserializing the object of type System.String. The input source is not correctly formatted. ---> System.Xml.XmlException: The input source is not correctly formatted.
 at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
 at System.Xml.XmlBufferReader.ReadValue(XmlBinaryNodeType nodeType, ValueHandle value)
 at System.Xml.XmlBinaryReader.ReadNode() …
Run Code Online (Sandbox Code Playgroud)

azureservicebus azure-webjobs azure-webjobssdk

5
推荐指数
1
解决办法
4175
查看次数

Azure 存储队列和多个 WebJobs 实例:QueueTrigger 是否会在触发时设置消息租用时间?

场景:生产者向存储队列发送消息,一个WebJobs在QueueTrigger上处理该消息,每条消息只能处理一次,可以有多个WebJob实例。

我一直在谷歌搜索,从我读过的内容来看,我需要编写处理消息的函数以使其具有幂等性,因此消息不会被处理两次。我还读到消息的默认租用时间为 10 分钟。

我的问题是,当在一个 WebJob 实例上触发 QueueTrigger 时,它是否设置了消息的租用时间,以便另一个 WebJob 无法获取相同的消息?如果是这样,为什么我需要考虑消息可以被处理两次的可能性?还是我误解了这一点?

azure-storage-queues azure-webjobs

5
推荐指数
1
解决办法
2468
查看次数

Azure WebJobs TimerTrigger 未触发

我正在尝试将 WebJob 作为控制台应用程序运行,当我添加时它可以工作RunOnStartup = true,但我需要它只与 TimerTrigger 一起工作。

这是我的代码

public static void Main()
{
  JobHostConfiguration config = new JobHostConfiguration();
  config.UseTimers();
  JobHost host = new JobHost(config);
  host.RunAndBlock();
} 

public static void TimerJob([TimerTrigger("0 0 8 * * *")] TimerInfo timerInfo)
{
    Console.WriteLine("Job Work");
}
Run Code Online (Sandbox Code Playgroud)

我需要什么才能使此代码工作?

azure azure-webjobs azure-webjobssdk

5
推荐指数
1
解决办法
6227
查看次数

Azure Webjobs - 使用 INameResolver 和 TimerTrigger 函数

我尝试使用 TimerTrigger 的简单功能配置作业。

public class Processor
{
    /// <summary>
    /// Initializes a new instance of the <see cref="Processor"/> class.
    /// </summary>
    public Processor()
    {

    }

    /// <summary>
    /// Process the Leads to Marketo.
    /// </summary>
    [Disable("Processor.Disable")]
    public async Task ProcessMessages([TimerTrigger("%Processor.TimerTrigger%")] TimerInfo timerInfo, TextWriter log)
    {


        // TODO : remove
        await Task.FromResult(0);
    }
}
Run Code Online (Sandbox Code Playgroud)

我的设置在我的 app.config 文件中定义:

<add key="Processor.TimerTrigger" value="00:01:00" />
<add key="Processor.Disable" value="false" />
Run Code Online (Sandbox Code Playgroud)

启动我的 webjob 时,我已将作业配置为使用 INameResolver 和 timertrigger:

static void Main()
{
    // Configure the job host
    var …
Run Code Online (Sandbox Code Playgroud)

azure-webjobs azure-webjobssdk

5
推荐指数
1
解决办法
1686
查看次数

拦截 Azure 函数主机关闭:刷新 Application Insights TelemetryClient

我正在使用 Azure Function:主要是我尝试将现有的 webjob 迁移到 Azure Functions,现在是时候将 Application Insights 集成到我的一个函数中了。

所以基本上我只需要一个实例,TelemetryClient但这假设我能够在应用程序停止时刷新内存缓冲区。

我使用了 TimerTrigger 但它只是为了测试目的。

我已经引用了Microsoft.ApplicationInsights nuget 包(来自这篇 SO 帖子),我的run.csx文件如下所示:

using System;
using Microsoft.ApplicationInsights;
using Microsoft.Azure.WebJobs;

public static void Run(TimerInfo myTimer, TraceWriter log)
{
    MyTimerJob.TelemetryClient.TrackEvent("AzureFunctionTriggered");
    log.Verbose($"C# Timer trigger function executed at: {DateTime.Now}");
}    

public static class MyTimerJob
{
    public static readonly TelemetryClient TelemetryClient;

    static MyTimerJob(){
        TelemetryClient = new TelemetryClient()
            { InstrumentationKey = "MyInstrumentationKey" };

        // When it shutdowns, we flush the telemty client.
        new …
Run Code Online (Sandbox Code Playgroud)

c# azure-webjobs azure-webjobssdk azure-application-insights azure-functions

5
推荐指数
1
解决办法
2456
查看次数

WebJobs SDK在AzureWebJobsDashboard连接中创建的blob清理机制是什么?

Azure的WebJob SDK使用在定义的存储连接字符串AzureWebJobsStorage,并AzureWebJobsDashboard为它的记录和仪表板应用程序设置.

WebJob SDK在以下位置创建以下blob容器AzureWebJobsStorage:

  • azure-webjobs-hosts

WebJob SDK在其中创建以下blob容器 AzureWebJobsDashboard

  • azure-jobs-host-output
  • azure-webjobs-hosts

当WebJob运行时,会在上面的blob容器中创建许多blob.如果没有清理机制,容器可能膨胀或饱和.

上面blob容器的清理机制是什么?

更新

以下答案是一种解决方法.此时,没有内置机制来清理WebJobs日志.作业长期运行时,日志可能会堆积很大.开发人员必须自己创建清理机制.Azure Functions是实现此类清理过程的好方法.以下答案中提供了一个示例.

azure azure-webjobs azure-webjobssdk

5
推荐指数
1
解决办法
785
查看次数

Web 作业上的 Python 库

我的目标是运行一个使用 Anaconda 库(例如 Pandas)的 Python 脚本,Azure WebJob但似乎无法弄清楚如何加载这些库。

我开始只是测试一个简单的 Azure blob 到 blob 文件副本,该副本在本地运行时可以工作,但"ImportError: No module named 'azure'"在 WebJob 中运行时遇到错误。

示例代码:

    from azure.storage.blob import BlockBlobService
    blobAccountName = <name>
    blobStorageKey = <key>  
    containerName = <containername>
    blobService = BlockBlobService(account_name=blobAccountName,
    account_key=blobStorageKey)
    blobService.set_container_acl(containerName)   
    b = blobService.get_blob_to_bytes(containerName, 'file.csv')
    blobService.create_blob_from_bytes(containerName, 'file.csv', b.content)
Run Code Online (Sandbox Code Playgroud)

我什至无法运行 Azure SDK 库。更不用说 Anaconda 的了

如何运行需要外部库(例如 Anaconda(甚至 Azure SDK))的 python 脚本。如何为 WebJob“pip install”这些东西?

python azure anaconda azure-webjobs

5
推荐指数
1
解决办法
4882
查看次数

Azure Web App - 无法为 SSL/TLS 安全通道建立信任关系

我在 Azure 中的同一个 Web 应用程序上运行了 Web 作业和 Web API。Web 作业通过 Https 访问 Web API。但是它在尝试访问 Web API 时抛出以下错误:

发送请求时发生错误。底层连接已关闭:无法为 SSL/TLS 安全通道建立信任关系。

azure azure-webjobs azure-web-app-service

5
推荐指数
1
解决办法
3069
查看次数

如何将手动创建的 Web 作业发布到 Azure

我按照这篇文章创建了一个面向 .NET Core 的 WebJobs 应用程序:http ://matt-roberts.me/azure-webjobs-in-net-core-2-with-di-and-configuration/

我必须手动执行此操作,因为当前 Visual Studio 不提供在其中创建WebJobs应用程序的方法,.NET Core但我可以.NET Core在 Visual Studio 2017 中创建控制台应用程序目标。

现在,我想将我的WebJobs控制台应用程序发布到 Azure,但我没有得到Publish as Azure WebJobVisual Studio 通常提供的选项——见下文: 在此处输入图片说明

相反,我只是得到“发布”选项,不确定这是否会按预期工作。

如何将手动创建的WebJobs控制台应用程序作为WebJob.

azure visual-studio azure-webjobs

5
推荐指数
1
解决办法
2457
查看次数