You may ask yourself how and where should we store the data in this kind of operation? The answer is Azure Storage. Azure storage is service for storing various data types and therefore it contains various types for you to choose from:
File
Simple, distributed, cross-platform file system
- Lift and shift migration
- Simple and inexpensive
- Move data to the cloud with no coding
Disk
Premium storage for I/O-intensive applications
- Low latency, high throughput
- Automatic triple replication
- Enterprise-grade durability
Blob
Massively-scalable object storage for unstructured data
- Cost-effective for massive volume
- Tiered storage options
- Single infrastructure with global reach
Queue
Durable queues for large-volume cloud services
- Simple, cost-effective messaging
- Decoupled component flexibility
- Resilient scaling and buffering
Table
Flexible NoSQL database
- Key-value table storage
- Structured or unstructured data
- Low latency at Internet scale
Archive
Low-cost storage for infrequently used data
- Data automatically encrypted at rest
- Seamless integration with hot and cool storage tiers
- Supported by leading Data Management partners
How to start working with Azure storage?
Now that we have everything let’s create a new Storage account on the Azure Portal:


How to create a queue triggered Web Job?
As you can see, message is pushed to a queue by simply serializing an object into JSON and creating CloudQueueMessage object and adding this message to queue.
//Push message to queue
var queueMessage = new CloudQueueMessage(JsonConvert.SerializeObject(entity));
queue.AddMessage(queueMessage);
Now that we have changed our first WebJob so that he will create a message and put it into queue let’s create a new WebJob:
Now that we have our template we will use generated Main method body and we will add additional method in Functions class
You maybe ask yourself what does the: “Please set the following connection strings in app.config for this WebJob to run: AzureWebJobsDashboard and AzureWebJobsStorage” means? For running WebJobs on Azure, you need to have Storage Account service. This is used for two reasons:
- Azure Storage is a data component extension to your Azure Storage for triggered operations with queue, blobs or tables (NoSQL)
- WebJobs is using Storage Account for storing logs.
Go to the Storage Account you’ve created earlier and go to the Manage Access Keys section and take the connection string and use them in your WebJob. You can use the same Azure Storage account for both connection strings.
Now that we add the keys we can create our QueueFunction method inside of a Functions class:
As you can see the important part of the function is in the first parameter:
[QueueTrigger(“fxrates”)] FXRatesInformation fxInfo
You have specified that you will be using Queue as a trigger and particular fxrates (the name of your queue container) and set FXRatesInformation as a message. This is how this object looks like:
As you see this is a plan .NET class and if you remember from the beginning we have serialized the same object in Continuous running WebJob into JSON. The beauty is that we didn’t have to deserialize the JSON into object again, the WebJob did this for us. And this are steps how you can create a queue triggered WebJob. You can use the same principle for blob storage. This is all on introduction of Azure WebJobs. Please check some interesting links below for additional information on Azure Storage and WebJobs:
Azure Storage Documentation
https://docs.microsoft.com/en-us/azure/storage/
Create a file share in Azure Files
https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-create-file-share
How to use Azure queue storage with the WebJobs SDK
https://github.com/Azure/azure-webjobs-sdk/wiki/Queues#manual
How to Send Email Using SendGrid with Azure
https://docs.microsoft.com/en-us/azure/sendgrid-dotnet-how-to-send-email
Run Background tasks with WebJobs in Azure App Service
https://docs.microsoft.com/en-us/azure/app-service/web-sites-create-web-jobs
Azure WebJob with .Net Core Console Application
http://www.intstrings.com/ramivemula/articles/azure-webjob-with-net-core-console-application/
Introducing Windows Azure WebJobs
https://www.hanselman.com/blog/IntroducingWindowsAzureWebJobs.aspx