I have a web app in ASP.NET Core RC1 in production and deployed in Azure with thousand of users using day a day.
I'm now upgrading my web project to RC2, following the tutorials I have found on Google (for example: Scott Blog, Official Doc, Tutorial1, Tutorial2, Tutorial3)
I need deploy the version RC2 when I have finished the upgrade without lose service to my users.
Do I need to create a new web app for the RC2 version or can I deploy in the same web app?
What is the way to implement that?
Thanks.
You can use Azure Deployment Slots. Develop and test your web application on you local, push it into the Staging slot. If it works fine there just swap the Staging Slot with the Production Slot. If the test fails there, don't worry, your actual application will still be running in production. Swap them carefully.
If you are using a storage with your web app, create a test (if possible) database in Azure for Staging Slot. If database is not an issue, you can use the same database with Staging and Production. Make sure that it works fine on your local system first.
Related
We have a .NET Core 2.1 Web App on Azure as an App Service. We deploy it to Azure via Visual Studio 2017's publish option (though it is also in a Git repo). It has a bunch of custom domains and SSL on all of them provided by Azure.
We've written a new version of the web app in .NET Core 3.1, in VS 2019. Identical functionality but written from the ground up rather than trying to upgrade the existing 2.1 version.
There's no staging version online as such - instead we develop on local machines and then just use test domains online that use the same service but where the environment is switched to use dev DBs and bucket locations etc, which is one of the reasons to write a new app rather than upgrade it, also, it just seemed cleaner and I saw that people had some issues when doing upgrades...
Is there an easy way to switch/publish the new web app/code into the current Azure App Service, to replace the old one? Or will I need to create a new App Service and then create all the custom domains, SSL etc there after removing them from the old one?
Or could I perhaps switch to git deployment and push the entire new project in over the old one - would that work or just create some kind of disaster?
There is usually no issue when pushing a new application version to your app service, even if it uses a new version of .NET Core.
You have to consider two things:
Windows AppService Plan: .NET Core 3.1 runtime has been rolled out worldwide, while the SDK has not (yet). When in doubt, use self-contained deployment.
Linux AppService Plan: You need to select the desired runtime version in the portal. Using e.g. Azure Pipelines you can set the runtime version at the same time as you publish the new version. Not sure how VisualStudio handles this.
As a general recommendation, you should follow silents suggestion of using slot deployments to have as little impact for your customers as possible. Each slot can have e.g. a different .NET runtime version, so you can test everything on the staging slots.
I'm using the ASP.NET Core & Angular startup template from ASP.NET Boilerplate with Multi-Tenancy disabled: 1 database with a single tenant(Default).
I'm also using TeamCity to build/test/publish the projects available in the startup template so I end up with 3 NuGet packages that are getting pushed to Octopus Deploy:
API (Host project, ASP.NET Core Web Application)
Migrator (Console application, capable of migrating the database(s))
UI (Angular App)
I want to deploy this setup to Azure with Octopus Deploy(self hosted, v2018.9.0) in the following way using 2 App Services(Host & UI) and 1 Azure SQL database(Host):
Take the UI and API applications offline, displaying a friendly maintenance message while updating the projects.
Migrate the database using the Migrator package
Deploy the API application package
Deploy the UI application package
Put the API application online, maybe some more tests to check that it's working correctly
Put the UI application online.
If all this was on-prem, I would have no questions. It's the Azure part that I can't figure out because I don't know how to do these things on Azure via Octopus Deploy:
Put an Azure App Service offline/online (using an app_offline.htm file)
Deploy the Migrator package to the API Azure App Service in a special folder(so that I don't overwrite the API deployment) and run the migrator: dotnet [migrator.dll] -q
I tried using the Octopus Deploy "Deploy an Azure Web App" but this step won't let me also deploy the migrator package and run it before the API package is deployed. Or does it? I don't know how.
I tried using the "Run an Azure PowerShell script" but this executes on the Octopus Deploy server and not on the Azure App Service environment right?
Maybe there are other, even better, approaches deploying this setup to Azure?
You can use App service slots to swap in/out version of your logical applications. When you swap there's a warming up that occurs and no loss of traffic.
So basically deploy to backup slot, then swap production with backup slot.
For the db I don't think your strategy is valid. There are some assumptions you are making that will not make your life easy. I would look at handling the db deployment separately with no breaking changes but that's my opinion.
I'm not familiar with Octopus or TeamCity so I won't go into details about those.
We have two web APIs hosted on azure for staging and production.
And we are consuming those APIs in mobile app where we provided which API should be used.
Right Now we are testing with staging app with staging mobile app.
If we do production app deployment and do swap slot from staging to production, does it will affect the staging app.
We have 2 different versions on hockeyapp staging and production mobile app. After swap slot does staging app will still point to staging API?
Should we standard API publish method.
Any help on this appreciated !
Slot swap switches the apps to the other slot.
So the app version in production will be running in staging and the one which was running in staging is now in production.
In my opinion you are using them a bit wrong here.
The purpose of deployment slots is to allow a "staged deployment" where new code can be published to the slot without bothering production, and then hot-swapped with minimal downtime.
What you really need is a testing environment, which you target from your testing app.
When deploying you deploy to staging and then swap to production.
I have setup continuous deployment of a standard web api project to an API App on Azure. The new version is deployed to the staging slot and then swapped with production at the end of the release task. I can see that (by going to App Service Editor in azure portal) the dll file versions reflect the latest changes. But when I access the APIs (from a webapp or postman) on this Azure app the result does not reflect the published changes. The only way I can force the new changes is either restarting the API app or stopping and starting the app service.
Am I missing anything in using continuous integration with API app on Azure?
I have solved this by adding a new task available in VSO release which restarts the staging slot before swapping with production. This makes sure that the new changes are part of the IIS process.
I've a MVC Web Application (.NET) and from time to time I need to upgrade the deployment version on Azure, the problem is that I have customers that are using the Web-App and I cant take it down and make it unavailable.
There is a way to deploy a new version of my Web-App and still be up and running the all time? (during the deployment process)
One way that I could think of it to do it is by deploy the the Web-App to somewhere other than my current deployment and "play" with the DNS record on my external domain.
Use deployment slots.
Azure Web Apps let you create staging slots for your site. They're effectively independent sites that you can deploy your test/staging bits to.
Then when you have the staging site ready you can push a button and make it your public production site.
See here for more details: https://azure.microsoft.com/en-us/documentation/articles/web-sites-staged-publishing/