When you Migrate your Existing Azure Mobile Service to an App Service you may want to take advantage of the slots available to you and create a Staging (and other) slot to test you code in. This will walk you through an easy way to do this.
Create the new slot in the portal and choose the parent site as the configuration source:
Test the slot to see if you can access it (note the difference in the domain… it is azurewebsites.net with –staging after the parent name):
Go to Kudu and download the entire parent site:
In Kudu, choose Debug Console and CMD… Click on the drive icon to download the entire site:
Now open the staging slot in Kudu and upload it.
Click on the Site folder and drag the zip file you just downloaded onto the right side of the directory as shown:
This will unzip the site and you will have a copy of that site!
You can test this staging site in Postman or Fiddler if you like and you will see it is still hitting the same database:
It is a good idea not to mess with production database so we will create a copy and point the staging slot to this copy.
Go to the Mobile Service database and choose Copy (in this case I am using the same server. If you choose a different server it gets more complicated and so I leave that to another post).
You will need to change the database connection string in the slot application settings to point to your test database.
Once that is finished it has copied the database schema and user login information from the original database.
All you need to do now is open the staging slot and change the database name in the connection strings:
Look for the Database part of the three connection strings listed below:
For example change:
Database=jsandersMultiAuthMobile_db; To Database=jsandersMultiAuthMobile_db_Staging;
For these strings:
MS_TableConnectionString (this one is used for Easy Tables)
Finally test in Postman by adding a record to the Staging site and ensure when you get the record it is not reflected in the production database!
Please drop me a note if you found this post useful!