6

I have an MVC website that is connected to an azure web app and has continuous deployment to a staging site set up. It works great! After I check in, the successful build is automatically deployed to the staging slot of my webapp. After I verify that staging looks good, I can swap the two slots to make prod into stage and vice versa.

Recently I decided that I wanted the production and staging slots to connect to distinct databases so that I can enter test data into the staging site without cluttering the prod database.

I naively though I could do this by editing the connection strings in the configuration for the staging site to point to a new database. It seemed to work, but the next time I swapped configurations after a deploy, I realized that the connection strings get swapped in the process. This is not what I was aiming for.

Does anyone know how I can have the two deployment slots point to different databases and to maintain those connections after the swap? Is there another way I should be thinking of this?

DanJosef
  • 323
  • 1
  • 3
  • 13

1 Answers1

5

Azure provides the answer here. I copy-edited their text below.

Some configuration elements will follow the content across a swap (not slot specific) while other configuration elements will stay in the same slot after a swap (slot specific).

Luckily, connection strings can be configured to stick to a slot. To configure a connection string to stick to a slot (not swapped), access the Application Settings blade for a specific slot, then select the Slot Setting box for the configuration elements that should stick the slot.

enter image description here

Maria Ines Parnisari
  • 14,229
  • 7
  • 73
  • 112