Exemple #1
0
        internal static string ToJsonString(this DeploymentTemplate template)
        {
            var serializationSettings = new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                ContractResolver  = new CamelCasePropertyNamesContractResolver()
            };

            var serializer = JsonSerializer.Create(serializationSettings);
            var textWriter = new StringWriter();

            serializer.Serialize(textWriter, template);
            return(textWriter.ToString());
        }
        internal static object CreateSlotCloneDeploymentTemplate(string location, string serverFarmId, string destinationWebAppName, string sourceWebAppId, string[] slotNames, HostingEnvironmentProfile hostingProfile, string apiVersion)
        {
            var template = new DeploymentTemplate
            {
                ContentVersion = ContentVersion,
                Schema         = "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                Parameters     = new Dictionary <string, ParameterType>
                {
                    { "time", new ParameterType
                      {
                          Type         = "string",
                          DefaultValue = "[utcNow()]"
                      } }
                },
                Variables = new Dictionary <string, object>
                {
                    { "slotNames", slotNames },
                    { "webAppName", destinationWebAppName },
                    { "sourceWebAppId", sourceWebAppId }
                },
                Resources = new WebAppResource[]
                {
                    new WebAppResource
                    {
                        Type       = WebAppSlotResourceType,
                        ApiVersion = apiVersion,
                        Location   = location,
                        Name       = WebAppSlotName,
                        Properties = new WebAppProperties
                        {
                            CloningInfo = new WebAppCloningInfo
                            {
                                SourceWebAppId = SourceWebAppSlotId,
                                CorrelationId  = "[guid(variables('slotNames')[copyIndex()], parameters('time'))]"
                            },
                            ServerFarmId = serverFarmId,
                            HostingEnvironmentProfile = hostingProfile
                        },
                        Copy = new CopyFunction
                        {
                            Name  = "SlotCopy",
                            Count = WebAppSlotCount
                        }
                    }
                }
            };

            return(template);
        }
Exemple #3
0
        internal static string CreateSlotCloneDeploymentTemplate(string location, string serverFarmId, string destinationWebAppName, string sourceWebAppId, string[] slotNames, HostingEnvironmentProfile hostingProfile, string apiVersion)
        {
            var template = new DeploymentTemplate
            {
                ContentVersion = ContentVersion,
                Schema         = "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                Variables      = new Dictionary <string, object>
                {
                    { "slotNames", slotNames },
                    { "webAppName", destinationWebAppName },
                    { "sourceWebAppId", sourceWebAppId }
                },
                Resources = new WebAppResource[]
                {
                    new WebAppResource
                    {
                        Type       = WebAppSlotResourceType,
                        ApiVersion = apiVersion,
                        Location   = location,
                        Name       = WebAppSlotName,
                        Properties = new WebAppProperties
                        {
                            CloningInfo = new CloningInfo
                            {
                                SourceWebAppId = SourceWebAppSlotId
                            },
                            ServerFarmId = serverFarmId,
                            HostingEnvironmentProfile = hostingProfile
                        },
                        Copy = new CopyFunction
                        {
                            Name  = "SlotCopy",
                            Count = WebAppSlotCount
                        }
                    }
                }
            };

            return(template.ToJsonString());
        }
        internal static string CreateSlotCloneDeploymentTemplate(string location, string serverFarmId, string destinationWebAppName, string sourceWebAppId, string[] slotNames, HostingEnvironmentProfile hostingProfile, string apiVersion)
        {
            var template = new DeploymentTemplate
            {
                ContentVersion = ContentVersion,
                Schema = "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                Variables = new Dictionary<string, object>
                {
                    { "slotNames", slotNames },
                    { "webAppName", destinationWebAppName },
                    { "sourceWebAppId", sourceWebAppId }
                },
                Resources = new WebAppResource[]
                {
                   new WebAppResource
                   {
                       Type = WebAppSlotResourceType,
                       ApiVersion = apiVersion,
                       Location = location,
                       Name = WebAppSlotName,
                       Properties = new WebAppProperties
                       {
                           CloningInfo = new CloningInfo
                           {
                               SourceWebAppId = SourceWebAppSlotId
                           },
                           ServerFarmId = serverFarmId,
                           HostingEnvironmentProfile = hostingProfile
                       },
                       Copy = new CopyFunction
                       {
                           Name = "SlotCopy",
                           Count = WebAppSlotCount
                       }
                   }
                }
            };

            return template.ToJsonString();
        }