Ben
Ben

Reputation: 329

Azure Deployment Slots - swapping and retaining connection strings

I recently swapped a staging Azure app into production with the "Swap with preview" function, and after completing the swap, the production app was pointing to the staging SQL DB connection string. In the app settings, I have the staging connection string saved and checked as a slot setting in the staging slot, and the production connection string saved and checked as a slot setting in the production slot.

Has anyone encountered this? I need the respective connection strings sticky to their respective slots, but in my case, the swap carried the source string to the target production slot, even though I THINK I configured the strings properly as slot settings and checked them in both environments.

Upvotes: 3

Views: 2152

Answers (2)

IronSean
IronSean

Reputation: 1578

Do you read the connection string every time you need it, or do you read the connection string once during the app startup and save it to an in memory value? The Startup.cs routine seems to only run once, and not re-run after a swap. So if you're reading the value during startup in your staging slot, then swapping to production that value won't be refreshed.

Upvotes: 0

viperguynaz
viperguynaz

Reputation: 12174

In AppSettings on the Azure Portal click the "Slot Setting" option next to your connection string: enter image description here

Upvotes: 0

Related Questions