public static string GetConfig(string slot) { const string _fmtGetProperties = "https://management.core.windows.net/{0}/services/hostedservices/{1}?embed-detail=true"; try { var requestUri = new Uri(string.Format(_fmtGetProperties, _devSubscriptionId, _devServiceName)); var api = new AzureMgmtApi { SubscriptionId = _devSubscriptionId, Certificate = AzureMgmtApi.GetCertificate(_certThumbprint) }; XDocument respBody; string reqId = api.InvokeRequest(requestUri, "GET", HttpStatusCode.OK, null, out respBody); Console.WriteLine("x-ms-request-id: " + reqId); respBody.Save(@"c:\users\brobichaud.corp\desktop\Properties.xml"); // parse the response XNamespace ns = "http://schemas.microsoft.com/windowsazure"; var configBase64 = (string)(from c in respBody.Descendants(ns + "Deployment") where c.Element(ns + "DeploymentSlot").Value == slot select c.Element(ns + "Configuration")).FirstOrDefault(); string config = DataEncoder.StringFromBase64(configBase64); var xml = new XmlIO() { IndentChars = " " }; string xmlConfig = xml.FormatFragment(config); Console.WriteLine("\n\nConfig:\n" + xmlConfig); File.WriteAllText(@"c:\users\brobichaud.corp\desktop\Config.xml", xmlConfig); return(config); } catch (Exception e) { Console.WriteLine("Error encountered: " + e.Message); return(null); } }