protected override string CreatePayload() { /*<?xml version="1.0" encoding="utf-8"?> <CreateHostedService xmlns="http://schemas.microsoft.com/windowsazure"> <ServiceName>service-name</ServiceName> <Label>base64-encoded-service-label</Label> <Description>description</Description> <Location>location</Location> <AffinityGroup>affinity-group</AffinityGroup> </CreateHostedService>*/ XNamespace ns = "http://schemas.microsoft.com/windowsazure"; var locationElement = !string.IsNullOrEmpty(AffinityGroup) ? new XElement(ns + "AffinityGroup", AffinityGroup) : new XElement(ns + "Location", Location); var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(ns + "CreateHostedService", new XElement(ns + "ServiceName", Name), new XElement(ns + "Label", Convert.ToBase64String(Encoding.UTF8.GetBytes(Name))), new XElement(ns + "Description", Description), locationElement)); return doc.ToStringFullXmlDeclaration(); }
//https://management.core.windows.net/<subscription-id>/services/hostedservices/<service-name>/deploymentslots/<deployment-slot-name>/?comp=status /// <summary> /// The Xml payload that is created and sent to the Fabric with the create deployment parameters /// </summary> /// <returns>A string Xml document representation</returns> protected override string CreatePayload() { XNamespace ns = "http://schemas.microsoft.com/windowsazure"; var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(ns + "UpdateDeploymentStatus", new XElement(ns + "Status", Status))); return doc.ToStringFullXmlDeclaration(); }
/// <summary> /// Creates a deployment payload for a predefined template /// </summary> /// <returns>A string xml representation</returns> /// POST https://management.core.windows.net/<subscription-id>/services/hostedservices/<service-name>/deployments/<deployment-name>/roleinstances/<role-name>/Operations protected override string CreatePayload() { /*<RestartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <OperationType>RestartRoleOperation</OperationType> </RestartRoleOperation>*/ XNamespace ns = "http://schemas.microsoft.com/windowsazure"; var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(ns + "RestartRoleOperation", new XElement(ns + "OperationType", "RestartRoleOperation"))); return doc.ToStringFullXmlDeclaration(); }
// POST https://management.core.windows.net/<subscription-id>/services/mobileservices/ /// <summary> /// The Xml payload that is created and sent to the Fabric with the create deployment parameters /// <?xml version="1.0" encoding="utf-8"?> /// <Application xmlns="http://schemas.microsoft.com/windowsazure"> /// <Name>##name##</Name> /// <Label>##label##</Label> /// <Description>##description##</Description> /// <Configuration>##spec##</Configuration> /// </Application> /// </summary> /// <returns>A string Xml document representation</returns> protected override string CreatePayload() { XNamespace ns = Namespaces.NsWindowsAzure; var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(ns + "Application", new XElement(ns + "Name", Name.ToLower() + "mobileservice"), new XElement(ns + "Label", Name.ToLower()), new XElement(ns + "Description", Description), new XElement(ns + "Configuration", Config))); return doc.ToStringFullXmlDeclaration(); }
/*<ServerFarm xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Name>DefaultServerFarm</Name> <NumberOfWorkers>2</NumberOfWorkers> <WorkerSize>Small</WorkerSize> </ServerFarm>*/ protected override string CreatePayload() { XNamespace xmlns = Namespaces.NsWindowsAzure; var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(xmlns + "Name", Website.ServerFarm.Name), new XElement(xmlns + "NumberOfWorkers", Website.ServerFarm.InstanceCount), new XElement(xmlns + "WorkerSize", Website.ServerFarm.InstanceSize)); return doc.ToStringFullXmlDeclaration(); }
protected override string CreatePayload() { XNamespace ns = "http://schemas.microsoft.com/windowsazure"; XNamespace array = "http://schemas.microsoft.com/2003/10/Serialization/Arrays"; var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(ns + "Site", new XElement(ns + "HostNames", new XElement(array + "string", Site.Name + ".azurewebsites.net")), new XElement(ns + "Name", Name), new XElement(ns + "State", State.ToString()))); return doc.ToStringFullXmlDeclaration(); }
protected override string CreatePayload() { XNamespace xmlns = "http://schemas.microsoft.com/2003/10/Serialization/Arrays"; if (!String.IsNullOrEmpty(Uri)) { var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(xmlns + "anyURI", Uri)); return doc.ToStringFullXmlDeclaration(); } return base.CreatePayload(); }
protected override string CreatePayload() { /* <?xml version="1.0" encoding="utf-8"?> <CreateStorageServiceInput xmlns="http://schemas.microsoft.com/windowsazure"> <ServiceName>service-name</ServiceName> <Description>service-description</Description> <Label>base64-encoded-label</Label> <AffinityGroup>affinity-group-name</AffinityGroup> <Location>location-of-the-storage-account</Location> </CreateStorageServiceInput>*/ XNamespace ns = "http://schemas.microsoft.com/windowsazure"; var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(ns + "CreateStorageServiceInput", new XElement(ns + "ServiceName", Name), new XElement(ns + "Description", Description), new XElement(ns + "Label", Convert.ToBase64String(Encoding.UTF8.GetBytes(Name))), new XElement(ns + "Location", Location))); return doc.ToStringFullXmlDeclaration(); }
protected override string CreatePayload() { /*<entry xmlns='http://www.w3.org/2005/Atom'> * <content type='application/xml'> * <NamespaceDescription xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.microsoft.com/netservices/2010/10/servicebus/connect\"> * <Region>{0}</Region> * </NamespaceDescription> * </content> * </entry>*/ // Serialize NamespaceDescription, if additional properties needs to be specified http://msdn.microsoft.com/en-us/library/jj873988.aspx XNamespace ns = "http://www.w3.org/2005/Atom"; XNamespace iXmlSchema = "http://www.w3.org/2001/XMLSchema-instance"; XNamespace serviceBusSchema = "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"; XName i = iXmlSchema + "i"; var doc = new XDocument( new XElement(ns + "entry", new XElement(ns + "content", new XAttribute("type", "application/xml"), new XElement(serviceBusSchema + "NamespaceDescription", new XAttribute(i, "http://www.w3.org/2001/XMLSchema-instance"), new XElement(serviceBusSchema + "Region", Location))))); return doc.ToStringFullXmlDeclaration(); }
/// <summary> /// Creates a deployment payload for a predefined template /// </summary> /// <returns>A string xml representation</returns> /// POST https://management.core.windows.net/<subscription-id>/services/hostedservices/<service-name>/deployments/<deployment-name>/roleinstances/<role-name>/Operations protected override string CreatePayload() { /*<ShutdownRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <OperationType>ShutdownRoleOperation</OperationType> * <PostShutdownAction>StoppedDeallocated</PostShutdownAction> </ShutdownRoleOperation>*/ XNamespace ns = "http://schemas.microsoft.com/windowsazure"; var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(ns + "ShutdownRoleOperation", new XElement(ns + "OperationType", "ShutdownRoleOperation"), new XElement(ns + "PostShutdownAction", "StoppedDeallocated"))); return doc.ToStringFullXmlDeclaration(); }
//https://management.core.windows.net/<subscription-id>/certificates/ /// <summary> /// The creation of the XML payload necessary to make the request /// </summary> protected override string CreatePayload() { XNamespace ns = "http://schemas.microsoft.com/windowsazure"; var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(ns + "CertificateFile", new XElement(ns + "Data", Base64CertificateData), new XElement(ns + "CertificateFormat", "pfx"), new XElement(ns + "Password", PfxPassword))); return doc.ToStringFullXmlDeclaration(); }
/// <summary> /// Creates an Xml payload for the /// </summary> /// <returns>The Xml string</returns> protected override string CreateXmlPayload() { /*<?xml version="1.0" encoding="utf-8"?> <ChangeConfiguration xmlns="http://schemas.microsoft.com/windowsazure"> <Configuration>base-64-encoded-configuration-file</Configuration> <TreatWarningsAsError>true|false</TreatWarningsAsError> <Mode>Auto|Manual</Mode> <ExtendedProperties> <ExtendedProperty> <Name>property-name</Name> <Value>property-value</Value> </ExtendedProperty> </ExtendedProperties> </ChangeConfiguration>*/ XNamespace ns = "http://schemas.microsoft.com/windowsazure"; var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(ns + "ChangeConfiguration", new XElement(ns + "Configuration", Convert.ToBase64String(Encoding.UTF8.GetBytes(Configuration.ToString()))), new XElement(ns + "Mode", "Auto"), new XElement(ns + "TreatWarningsAsError", true.ToString().ToLower()))); return doc.ToStringFullXmlDeclaration(); }
/// <summary> /// This method builds up wht payload but currently only builds the logging and not the hourly or minute metrics /// </summary> private string BuildXmlPayload() { var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement("StorageServiceProperties", new XElement("Logging", new XElement("Version", "1.0"), new XElement("Delete", "true"), new XElement("Read", "true"), new XElement("Write", "true"), new XElement("RetentionPolicy", new XElement("Enabled", "true"), new XElement("Days", "7"))))); return doc.ToStringFullXmlDeclaration(); }
/// <summary> /// Creates a deployment payload for a predefined template /// </summary> /// <returns>A string xml representation</returns> /// POST https://management.core.windows.net/<subscription-id>/services/hostedservices/<service-name>/deployments/<deployment-name>/roleinstances/<role-name>/Operations protected override string CreatePayload() { /*<OSImage xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Label>image-label</Label> <MediaLink>uri-of-the-containing-blob</MediaLink> <Name>image-name</Name> <OS>Linux|Windows</OS> <Eula>image-eula</Eula> <Description>image-description</Description> <ImageFamily>image-family</ImageFamily> <PublishedDate>published-date</PublishedDate> <IsPremium>true/false</IsPremium> <ShowInGui>true/false</ShowInGui> <PrivacyUri>http://www.example.com/privacypolicy.html</PrivacyUri> <IconUri>http://www.example.com/favicon.png</IconUri> <RecommendedVMSize>Small/Large/Medium/ExtraLarge</RecommendedVMSize> <SmallIconUri>http://www.example.com/smallfavicon.png</SmallIconUri> <Language>language-of-image</Language> </OSImage>*/ XNamespace ns = "http://schemas.microsoft.com/windowsazure"; var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(ns + "OSImage", new XElement(ns + "Label", Properties.Label), new XElement(ns + "MediaLink", Properties.MediaLink), new XElement(ns + "Name", Properties.Name), new XElement(ns + "OS", Properties.OperatingSystem.ToString()), new XElement(ns + "PublishedDate", Properties.PublishedDate.ToString("s")), new XElement(ns + "IsPremium", Properties.IsPremium.ToString().ToLowerInvariant()), new XElement(ns + "ShowInGui", Properties.ShowInGui.ToString().ToLowerInvariant()))); return doc.ToStringFullXmlDeclaration(); }
protected override string CreateXmlPayload() { XNamespace ns = SqlAzureSchema; var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(ns + "Server", new XElement(ns + "AdministratorLogin", AdministratorLogin), new XElement(ns + "AdministratorLoginPassword", AdministratorPassword), new XElement(ns + "Location", Location))); return doc.ToStringFullXmlDeclaration(); }
protected override string CreatePayload() { XNamespace xmlns = "http://schemas.microsoft.com/windowsazure"; XNamespace i = "http://www.w3.org/2001/XMLSchema-instance"; XNamespace a = "http://schemas.microsoft.com/2003/10/Serialization/Arrays"; XName iNamespace = XNamespace.Xmlns + "i"; XName iNil = i + "nil"; XName aArray = XNamespace.Xmlns + "a"; XName aString = a + "string"; if (Website.Config == null) { throw new FluentManagementException("Website configuration is not currently available", "UpdateWebsiteConfigCommand"); } var doc = new XDocument(new XDeclaration("1.0", "utf-8", "")); var root = new XElement(xmlns + "SiteConfig", new XAttribute(iNamespace, i), new XAttribute(aArray, a)); #region boolean properties // get the compute modefrom the instance var detailedErrorLoggingEnabled = new XElement(xmlns + "DetailedErrorLoggingEnabled", Website.Config.DetailedErrorLoggingEnabled); // get the compute modefrom the instance var httpLoggingEnabled = new XElement(xmlns + "HttpLoggingEnabled", Website.Config.HttpLoggingEnabled); // get the compute modefrom the instance var requestTracingEnabled = new XElement(xmlns + "RequestTracingEnabled", Website.Config.RequestTracingEnabled); // get the compute modefrom the instance var use32BitWorkerProcess = new XElement(xmlns + "Use32BitWorkerProcess", Website.Config.Use32BitWorkerProcess); #endregion #region string and int values XElement netFrameworkVersion = null, phpVersion = null, publishingPassword = null, publishingUsername = null, numberOfWorkers = null; // this is the type of source control used var scmType = new XElement(xmlns + "ScmType", Website.Config.ScmType); // add the publishing password if (Website.Config.PhpVersion != null) { netFrameworkVersion = new XElement(xmlns + "NetFrameworkVersion", Website.Config.NetFrameworkVersion); } // add the publishing password if (Website.Config.PhpVersion != null) { phpVersion = new XElement(xmlns + "PhpVersion", Website.Config.PhpVersion); } // add the publishing password if (Website.Config.PublishingPassword != null) { publishingPassword = new XElement(xmlns + "PublishingPassword", Website.Config.PublishingPassword); } // add the publishing username if (Website.Config.PublishingUsername != null) { publishingUsername = new XElement(xmlns + "PublishingUsername", Website.Config.PublishingUsername); } // add the number of workers if (Website.Config.NumberOfWorkers > 0) { numberOfWorkers = new XElement(xmlns + "NumberOfWorkers", Website.Config.NumberOfWorkers); } #endregion #region collection values // build appsettings var appSettings = new XElement(xmlns + "AppSettings"); foreach (var appSetting in Website.Config.AppSettings) { appSettings.Add(new XElement(xmlns + "NameValuePair", new XElement(xmlns + "Name", appSetting.Key), new XElement(xmlns + "Value", appSetting.Value))); } // build metadata var metadatas = new XElement(xmlns + "Metadata"); foreach (var metadata in Website.Config.Metadata) { metadatas.Add(new XElement(xmlns + "NameValuePair", new XElement(xmlns + "Name", metadata.Key), new XElement(xmlns + "Value", metadata.Value))); } // build connection strings var connectionStrings = new XElement(xmlns + "ConnectionStrings"); foreach (var connectionString in Website.Config.ConnectionStrings) { connectionStrings.Add(new XElement(xmlns + "ConnStringInfo", new XElement(xmlns + "ConnectionString", connectionString.ConnectionString), new XElement(xmlns + "Name", connectionString.Name), new XElement(xmlns + "Type", connectionString.Type))); } // add the default documents var defaultDocuments = new XElement(xmlns + "DefaultDocuments"); foreach (var defaultDocument in Website.Config.DefaultDocuments) { defaultDocuments.Add(new XElement(a + "string", defaultDocument)); } #endregion // add the elements to the root node root.Add(appSettings); root.Add(connectionStrings); root.Add(defaultDocuments); root.Add(detailedErrorLoggingEnabled); root.Add(httpLoggingEnabled); root.Add(metadatas); if (netFrameworkVersion != null) root.Add(netFrameworkVersion); if (numberOfWorkers != null) root.Add(numberOfWorkers); if (phpVersion != null) root.Add(phpVersion); if (publishingPassword != null) root.Add(publishingPassword); if (publishingUsername != null) root.Add(publishingUsername); root.Add(requestTracingEnabled); root.Add(scmType); root.Add(use32BitWorkerProcess); doc.Add(root); return doc.ToStringFullXmlDeclaration(); }
/*<Site xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <AdminEnabled i:nil="true"/> <AvailabilityState>Normal</AvailabilityState> <Enabled i:nil="true"/> <EnabledHostNames i:nil="true" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/> <HostNameSslStates i:nil="true"/> <HostNames xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <a:string>clitest37.azurewebsites.net</a:string> </HostNames> <Name>clitest37</Name> <Owner i:nil="true"/> <RepositorySiteName i:nil="true"/> <SSLCertificates i:nil="true"/> <SelfLink i:nil="true"/> <SiteMode i:nil="true"/> <SiteProperties i:nil="true"/> <State i:nil="true"/> <UsageState>Normal</UsageState> <WebSpace>northeuropewebspace</WebSpace> <WebSpaceToCreate> <AvailabilityState>Normal</AvailabilityState> <ComputeMode>Dedicated</ComputeMode> <CurrentNumberOfWorkers>1</CurrentNumberOfWorkers> <CurrentWorkerSize>Small</CurrentWorkerSize> <Name>northeuropewebspace</Name> <NumberOfWorkers>1</NumberOfWorkers> <Status>Ready</Status> <WorkerSize>Small</WorkerSize> </WebSpaceToCreate> </Site>*/ protected override string CreatePayload() { XNamespace xmlns = "http://schemas.microsoft.com/windowsazure"; XNamespace i = "http://www.w3.org/2001/XMLSchema-instance"; XNamespace a = "http://schemas.microsoft.com/2003/10/Serialization/Arrays"; XName iNamespace = XNamespace.Xmlns + "i"; XName iNil = i + "nil"; XName aArray = XNamespace.Xmlns + "a"; XName aString = a + "string"; var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(xmlns + "Site", new XAttribute(iNamespace, i), new XElement(xmlns + "AdminEnabled", new XAttribute(iNil, "true")), new XElement(xmlns + "AvailabilityState", Website.WebsiteParameters.AvailabilityState), new XElement(xmlns + "Enabled", new XAttribute(iNil, "true")), new XElement(xmlns + "EnabledHostNames", new XAttribute(iNil, "true"), new XAttribute(aArray, a)), new XElement(xmlns + "HostNameSslState", new XAttribute(iNil, "true"), new XAttribute(aArray, a)), new XElement(xmlns + "HostNames", new XAttribute(aArray, a), new XElement(aString, Website.Name + WebsitePostfix)), //new XElement(aString, Website.Name + ".scm" + WebsitePostfix)), new XElement(xmlns + "Name", Website.Name), new XElement(xmlns + "Owner", new XAttribute(iNil, "true")), new XElement(xmlns + "RepositorySiteName", Website.Name), new XElement(xmlns + "SSLCertificates", new XAttribute(iNil, "true")), new XElement(xmlns + "SelfLink", new XAttribute(iNil, "true")), new XElement(xmlns + "SiteMode", new XAttribute(iNil, "true")), new XElement(xmlns + "SiteProperties", new XAttribute(iNil, "true")), new XElement(xmlns + "State", new XAttribute(iNil, "true")), new XElement(xmlns + "UsageState", Website.Usage), new XElement(xmlns + "WebSpace", Website.Webspace), new XElement(xmlns + "WebSpaceToCreate", new XElement(xmlns + "AvailabilityState", Website.WebsiteParameters.AvailabilityState), new XElement(xmlns + "ComputeMode", Website.ComputeMode), new XElement(xmlns + "CurrentNumberOfWorkers", Website.WebsiteParameters.CurrentNumberOfWorkers), new XElement(xmlns + "CurrentWorkerSize", Website.WebsiteParameters.CurrentWorkerSize), new XElement(xmlns + "Name", Website.Webspace), new XElement(xmlns + "NumberOfWorkers", Website.WebsiteParameters.CurrentNumberOfWorkers), new XElement(xmlns + "Status", Website.State), new XElement(xmlns + "WorkerSize", Website.WebsiteParameters.CurrentWorkerSize)))); return doc.ToStringFullXmlDeclaration(); }
//https://management.core.windows.net/<subscription-id>/services/hostedservices/<service-name>/deploymentslots/<deployment-slot-name> /// <summary> /// The Xml payload that is created and sent to the Fabric with the create deployment parameters /// </summary> /// <returns>A string Xml document representation</returns> protected override string CreateXmlPayload() { XNamespace ns = "http://schemas.microsoft.com/windowsazure"; var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(ns + "CreateDeployment", new XElement(ns + "Name", Name), new XElement(ns + "PackageUrl", PackageUri), new XElement(ns + "Label", Convert.ToBase64String(Encoding.UTF8.GetBytes(DeploymentName))), new XElement(ns + "Configuration", Config), new XElement(ns + "StartDeployment", StartDeploymentAutomatically.ToString().ToLower()), new XElement(ns + "TreatWarningsAsError", TreatWarningsAsErrors.ToString().ToLower()))); return doc.ToStringFullXmlDeclaration(); }
protected override string CreatePayload() { XNamespace ns = SqlAzureSchema; var doc = new XDocument( new XDeclaration("1.0", "utf-8", ""), new XElement(ns + "FirewallRule", new XElement(ns + "StartIpAddress", SqlAzureClientIpAddressLow), new XElement(ns + "EndIpAddress", SqlAzureClientIpAddressHigh))); return doc.ToStringFullXmlDeclaration(); }