Answered by:
Swap staging programatically via REST api

Question
-
I'm looking for a way to swap the staging and production slots of a WebSite programmatically. I have done this for many moons with Cloud Services but can't seem to find the REST api to do it with WebSites. I am aware of the Switch-AzureWebsiteSlot powershell cmdlet but I don't want that, I need to do it from code in a winforms app we use for deployments.
Any ideas?
- Edited by Curious George Tuesday, June 3, 2014 8:50 PM
Tuesday, June 3, 2014 8:48 PM
Answers
-
Hi George. There is public REST API for this but it looks like it has not been documented yet here (http://msdn.microsoft.com/en-us/library/azure/dn236427.aspx).
The REST API URL to swap staging and production slots looks like this:
Where {siteName} is in this format sitename(slotName). For example if you have site with name mysite and it has staging and production slots, then the URL will be:
http://ruslany.net/
- Edited by RuslanY Thursday, June 5, 2014 4:18 PM
- Marked as answer by Curious George Thursday, June 5, 2014 4:30 PM
Thursday, June 5, 2014 4:15 PM
All replies
-
You should be able to do this using Microsoft.WindowsAzure.Management.WebSites.
See this post to get started with the library.
- Marked as answer by Curious George Wednesday, June 4, 2014 3:16 PM
- Unmarked as answer by Curious George Tuesday, June 24, 2014 1:11 AM
Tuesday, June 3, 2014 9:09 PM -
Ah, I didn't go down this path as I had my mind set on using the Rest Api. I'll take a look. Though I do wonder if a public Rest Api to do this is forthcoming to stay consistent with other parts of Azure. I'm sure under the covers this Mgmt Library must be using a Rest Api.Wednesday, June 4, 2014 3:17 PM
-
Hi George,
Yes, there is a REST API under the cover. It's documented here, but unfortunately it appears to be out of date, and does not cover the Swap API. Yes, we need to fix that :)
David
Wednesday, June 4, 2014 4:35 PM -
Ah, so the reality is that there is a public Rest api I could use, it just happens to not yet be documented? Please do update the docs! It would have saved me the hassle here.
Thanks for the help.
Wednesday, June 4, 2014 4:38 PM -
Hi George. There is public REST API for this but it looks like it has not been documented yet here (http://msdn.microsoft.com/en-us/library/azure/dn236427.aspx).
The REST API URL to swap staging and production slots looks like this:
Where {siteName} is in this format sitename(slotName). For example if you have site with name mysite and it has staging and production slots, then the URL will be:
http://ruslany.net/
- Edited by RuslanY Thursday, June 5, 2014 4:18 PM
- Marked as answer by Curious George Thursday, June 5, 2014 4:30 PM
Thursday, June 5, 2014 4:15 PM -
Awesome! Thank you RuslanY, I will give it a try.Thursday, June 5, 2014 4:30 PM