12

Azure Deployment Slot is Awesome functionality for regular(Full) production deployment build process using Deployment Slot Swap functionality.

But sometimes we need to deploy the hotfix on production, like need to change only in the web.config or some static files which really don’t required the complete deployment life cycle, then how we can do the hotfix deployment(partially deployment) using staging slot swapping functionality as my staging slot is not up-to-date, its contain the old stuff( before the last build deployment)

Consider the below scenario:

Deployed full site to staging before production, now staging is latest

Swap to production, now production is latest, staging become old

Now suppose, we need to deploy the hot fix by changing the value in the web.config, which we can directly change in the staging slot without process with full deployment, but we cannot swap the staging slot with production as staging slot don't have the current version of the website?

I wish there should be one button called copy from production addition to swap button, so firstly we quickly copy the production content into staging slot, change on staging slot, verify the changes and boom for production swap.

What should be the best approach for this type of deployment? Please suggest

4
  • 4
    Your problem here is that you do hotfixes directly on production... that sounds very risky. Any change to a production site should be done with a deployment process - the process is there to stop scenarios like you have described happening and will reduce the risk of human error. Bypassing those processes will cause you problems. The real answer is, change your process. Don't ever manually modify production files.
    – Richard Seal
    Nov 2, 2017 at 17:02
  • 1
    Hi Richard you are correct, we don’t do any direct changes on production, everything is by process only, just wondering is there any way to refresh the staging slot from production Nov 2, 2017 at 22:11
  • Well you would only need to deploy the solution files there right? The main set of files would be provisioned from the initial setup of the app service. So I'm not sure why just deploying your solution to the stage slot wouldn't work.
    – Richard Seal
    Nov 2, 2017 at 22:14
  • 2
    HI Richard, The standard process that we follow is: commit the code in source code, automatic build trigger(team city) and create the package and deploy in the various environments through octopus, Till production using staging slot swapping functionality that all is fine, but recently we faced one scenario , where octopus was not working(some intermediate problem) and couldn't deployed the build through octopus(full deployment) on production and had to deploy one config changes urgently on production, and I wished to test on staging first, but couldn't as my staging slot was not updated. Nov 2, 2017 at 22:33

7 Answers 7

2

In our case we do this like this:

  1. Generate deployment package (with the fix)
  2. Deploy it to staging slot
  3. Test it on staging stot
  4. Swap the slots
  5. Test on live again

So we do not copy manually any files from production slot to staging slot etc. We just do a full deploy to staging slot (with the fix). Test it there and swap at the end.

1

You can download Publish profile for your web app. It contains FTP access to your application root. You can use any FTP client such as FileZila to connect with your Azure website root and deploy hot fix using that if you dont wish to go for full deployment.

Also there is Kudu developer console on Azure portal which will be helpful in such scenarios.

Publish Profile

enter image description here

Kudu Developer Tools

enter image description here

2
  • 1
    Hi Mohit, I need the feature of deployment slot switch using staging slot for verification then build before production , is there any way to clone/copy the production slot to staging slot? Oct 4, 2017 at 21:31
  • Not the one I'm aware of. But why don't you go for full deployment to staging slot and then swapping. The slot is meant for high availability and Continuous Delivery. Even you have static changes you will going to check in those files and DevOps process can trigger the deployment. Oct 5, 2017 at 9:39
1

You could create the slot using New-AzWebAppSlot PowerShell script. Passing the SourceWebApp parameter will ensure the code from the source app is used when creating the slot.

1

I was able to accomplish a 'copy' from Production to Staging by creating a backup through the Azure Portal UI and then clicking Restore on the backup, which allowed me to restore the backup contents to my Staging slot. Accomplished my goal, FWIW..

-Jay

0

Agree with the recommendation above, always following your CI/CD pipeline/process is the safest and more repeatable way to accomplish that.

But in case you need to copy production slot to another slot, here are some PowerShell commands you could get inspiration of: https://github.com/mathieu-benoit/copy-azurewebapp-to-slot. Be careful, it's experimental and need to be used and tested to see the impact, pieces missing, etc.

0

One thing I don't like about swap as opposed to copy is your Staging now becomes old incorrect code. Makes total sense to be able to copy to an intermediate (your new slot mentioned above) slot and swap out the intermediate slot to production.

0

I found a way to copy the content of the Production slot into the existing Staging slot.

Browse to your App Service --> Backups --> Select the Backup that you want --> Click on Restore --> Select your target slot in place of Deployment slot.

If you want the entire configurations, check the box beside Restore site configuration under Advanced Options. Note: This option may time a maximum of 30minutes depending on the size of our app.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.