0

I'm looking to use the Change Feed Processor SDK to monitor for changes to an Azure Cosmos DB collection, however, I have not seen clear documentation about whether the host can be run as an Azure Web Job. Can it? And if yes, are there any known issues or limitations versus running it as a Console App?

There are a good number of blog posts about using the CFP SDK, however, most of them vaguely mention running the host on a VM, and none of them or any examples running the host as an azure web job.

Even if it's possible, as a side question is, if such a host is deployed as a continuous web job and I select the "Scale" setting of the web job to Multi Instance, what are the approaches or recommendations to make the extra instances run with a different instance name, which the CFP SDK requires?

GR7
  • 5,083
  • 8
  • 48
  • 66
  • Is there a reason why you wouldnt simply use Azure Functions? – silent Jan 05 '20 at 13:36
  • @silent I'm just evaluating all approaches. – GR7 Jan 05 '20 at 16:52
  • Hi,any updates here?Does my answer helps you? – Jay Gong Jan 16 '20 at 07:06
  • Hi Jay. Yes, I already marked it as an answer. Like I said, I was evaluating all approaches. Because my particular use case required retries of processing a document with a wait time of minutes in between retries, I ended up not using Change Feed, but Azure Storage Queues and a Function bound to the queue. Thanks anyways! Will certainly play with the CF just for fun in the near future. – GR7 Jan 16 '20 at 20:22

2 Answers2

1

According to my research,Cosmos db trigger could be implemented in the WebJob SDK.

static async Task Main()
{
    var builder = new HostBuilder();
    builder.ConfigureWebJobs(b =>
    {
        b.AddAzureStorageCoreServices();
        b.AddCosmosDB(a =>
        {
            a.ConnectionMode = ConnectionMode.Gateway;
            a.Protocol = Protocol.Https;
            a.LeaseOptions.LeasePrefix = "prefix1";

        });
    });
    var host = builder.Build();
    using (host)
    {
        await host.RunAsync();
    }
}

But it seems only Nuget for c# sdk could be used,no clues for other languages.So,you could refer to the Compare Functions and WebJobs to balance your needs and cost.

enter image description here

Jay Gong
  • 23,163
  • 2
  • 27
  • 32
1

The Cosmos DB Trigger for Azure Functions it's actually, a WebJobs extension: https://github.com/Azure/azure-webjobs-sdk-extensions/tree/dev/src/WebJobs.Extensions.CosmosDB And it uses the Change Feed Processor.

Functions run over WebJob technology. So to answer the question, yes, you can run Change Feed Processor on WebJobs, just make sure that:

  1. Your App Service is set to Always On
  2. If you plan to use multiple instances, make sure to set the InstanceName accordingly and not a static/fixed value. Probably something that identifies the WebJob instance.
Matias Quaranta
  • 13,907
  • 1
  • 22
  • 47