I'd like to know what is the best practice for doing incremental production deployment in azure with servicebus,
How to ensure that the messages don't get deleted when deploying a new version
Is there a backup mechanism to save the messages and load it back after the deployment is complete?
The Windows Azure Service Bus is a service which runs outside of your deployment, similar to Windows Azure SQL Database or Windows Azure Storage. This means that it does not depend on your deployment: you can deploy, remove, re-deploy your application without impacting the messages present in the Service Bus.
The only thing you'll need to take care of when you deploy a new version of your application is that the messages available in Service Bus Queues / Subscriptions might have been sent by the old version of the application. So take into account that the new version of your application will need to be compatible with these "old" message formats.
Related
I have some containers deployed on Azure App Service. To achieve zero downtime, Azure recommends using Deployment slots and swapping the staging and production slots. This is fine for a normal web applications, but If I have a web app where I am also doing other stuff like reading messages from queues, running workers in the background etc.
How do I ensure that the container is terminated in a graceful manner. Do Azure sends some kind of signal to the docker container indicating that it is terminating the application, so we should do cleanups. If not, how can I make my app truly zero downtime deployable hosted in App Service?
but I have a web app where I am also doing other stuff like reading messages from queues, running workers in the background etc.
This design is going to make it very difficult for you to do zero-downtime upgrades. I would recommend splitting the different purposes, and deploy them on different azure resources which can be upgraded in different ways:
your web app runs on Azure App Service, with blue/green upgrades using deployment slots
worker processes, and queue processing, could each be done by Azure Functions, which have their own version of deployment slots for zero-downtime upgrades
My app needs a background service that constantly receives and handles events streamed from an Azure Event Hub.
I see that Azure Functions has built-in triggers for this, but the problem is that my app is written in .NET 5 and Azure Function support for it is fairly immature at this point.
I also see from this documentation that .NET has an readily-made SDK Azure.Messaging.EventHubs. My understanding is that this will run as a console app.
I'm already using the Azure App Service (Linux plan) to host the main web app.
So if I create a console app using Azure.Messaging.EventHubs, I'd want to deploy it as something like a web job, but the Linux app service plan doesn't support it. I guess I can deploy the console app it to a separate Windows App Service plan.
What's the next best option? Are there any practical differences compared to using Azure Functions?
There's also this .NET Core Worker Service that's more optimized for background services. I wonder if there's a place for it in this use case.
These options are confusing me a bit. Your advices would be greatly appreciated.
Azure function should be the best choice. It has the built-in eventhub trigger and process logic, and easy to setup / configure(like logging via Application Insights) / less code to write. And recently(Mar 10 2021), it is supported for running production .NET 5 apps on Azure Functions. I suggest you can give it a try and use it if no issues.
For azure webjobs, in this case, if you're directly using the SDK, you need to write many codes and configure something like logging.
For .NET Core Worker Service, it can also be published as azure webjobs if you want to use it. You can follow this doc on how to publish worker service as azure webjob.
I have a console application connecting to database and executing DML transactions. This console application is currently scheduled using windows task scheduler. I am planning to migrate this to Azure.
Which is the recommended strategy ?
Should this be moved as Azure webjobs or function apps ?
Since you already have a console project, then it's more easier to use Azure Webjobs to achieve that.
To create a webjob, just create a .zip file which includes the .exe / .dll and other necessary files, then upload to azure. For schedule, please refer to Create a scheduled WebJob. For more details, you can refer to this doc.
Note: there're some limitation of azure webjobs / azure function, see Azure-Web-App-sandbox. But if you only need to connecting to database and executing DML transactions, you can ignore the limits.
And yes, you can also do this via azure function, but since you already have a console project, it's easier to use webjobs.
I'm about to use Azure Service Bus and I'm going to have at least 4 environments that will be used for different parts of the development process, i.e. Build, Test, more Testing, and finally Production.
I would like to export my set of Queues and Topics from my namespace(s) and deploy them to other environments.
Does Azure offer a way of doing this, or do I need to create something myself?
You can use Azure Resource Manager to create a template to deploy your namespace with a set of queues and topics (with topic subscriptions).
To configure your template for Azure Resource Manager, see https://azure.microsoft.com/en-us/documentation/articles/vs-azure-tools-resource-group-adding-resources/
You cannot add the configuration for a service bus with the GUI of Visual Studio but you can do it manually by following this template : https://github.com/sjkp/Azure.ARM.ServiceBus/blob/master/Azure.ARM.ServiceBus/Templates/DeploymentTemplate.json
Currently, the configuration for service bus is not well documented...
I got a cloud service (worker role) which I want to deploy to a beta and a production environment.
It seems a waste to have to create three projects (one with the actual implementation and two for deployment).
Is it possible to create two deployment profiles which links to different Azure destinations but uses the same worker role project?
This is very simple to do. Just build your Azure package without deploying, and keep your dev/beta/prod settings in the Service Configuration, not embedded anywhere like web.config/app.config. Then store both the deployment package and configuration in blob storage (speeding up deployment). You'll want multiple configuration files: one for each environment, each stored separately in blob storage.
Once this is done, you can just deploy the package to multiple cloud services, each with a different configuration file. This can be done either through the portal or through PowerShell / CLI.
If you've been deploying directly from Visual Studio, it might not seem quite as obvious. But from VS, you can build a package without actually deploying.