コード例 #1
0
        internal static WebSiteUpdateConfigurationParameters ToUpdate(this WebSiteGetConfigurationResponse getConfigResponse)
        {
            var update = new WebSiteUpdateConfigurationParameters
            {
                DetailedErrorLoggingEnabled = getConfigResponse.DetailedErrorLoggingEnabled,
                HttpLoggingEnabled          = getConfigResponse.HttpLoggingEnabled,
                NetFrameworkVersion         = getConfigResponse.NetFrameworkVersion,
                NumberOfWorkers             = getConfigResponse.NumberOfWorkers,
                PhpVersion                   = getConfigResponse.PhpVersion,
                PublishingPassword           = getConfigResponse.PublishingPassword,
                PublishingUserName           = getConfigResponse.PublishingUserName,
                RequestTracingEnabled        = getConfigResponse.RequestTracingEnabled,
                RequestTracingExpirationTime = getConfigResponse.RequestTracingExpirationTime,
                ScmType = getConfigResponse.ScmType,
                Use32BitWorkerProcess = getConfigResponse.Use32BitWorkerProcess
            };

            getConfigResponse.AppSettings.ForEach(kvp => update.AppSettings.Add(kvp.Key, kvp.Value));
            getConfigResponse.ConnectionStrings.ForEach(cs => update.ConnectionStrings.Add(new WebSiteUpdateConfigurationParameters.ConnectionStringInfo
            {
                ConnectionString = cs.ConnectionString,
                Name             = cs.Name,
                Type             = cs.Type
            }));
            getConfigResponse.DefaultDocuments.ForEach(dd => update.DefaultDocuments.Add(dd));
            getConfigResponse.HandlerMappings.ForEach(hm => update.HandlerMappings.Add(new WebSiteUpdateConfigurationParameters.HandlerMapping
            {
                Arguments       = hm.Arguments,
                Extension       = hm.Extension,
                ScriptProcessor = hm.ScriptProcessor
            }));
            getConfigResponse.Metadata.ForEach(kvp => update.Metadata.Add(kvp.Key, kvp.Value));

            return(update);
        }
コード例 #2
0
        internal static WebSiteUpdateConfigurationParameters ToUpdate(this WebSiteGetConfigurationResponse getConfigResponse)
        {
            var update = new WebSiteUpdateConfigurationParameters
            {
                DetailedErrorLoggingEnabled = getConfigResponse.DetailedErrorLoggingEnabled,
                HttpLoggingEnabled = getConfigResponse.HttpLoggingEnabled,
                NetFrameworkVersion = getConfigResponse.NetFrameworkVersion,
                NumberOfWorkers = getConfigResponse.NumberOfWorkers,
                PhpVersion = getConfigResponse.PhpVersion,
                PublishingPassword = getConfigResponse.PublishingPassword,
                PublishingUserName = getConfigResponse.PublishingUserName,
                RequestTracingEnabled = getConfigResponse.RequestTracingEnabled,
                RequestTracingExpirationTime = getConfigResponse.RequestTracingExpirationTime,
                ScmType = getConfigResponse.ScmType,
                Use32BitWorkerProcess = getConfigResponse.Use32BitWorkerProcess
            };

            getConfigResponse.AppSettings.ForEach(kvp => update.AppSettings.Add(kvp.Key, kvp.Value));
            getConfigResponse.ConnectionStrings.ForEach(cs => update.ConnectionStrings.Add(new WebSiteUpdateConfigurationParameters.ConnectionStringInfo
            {
                ConnectionString = cs.ConnectionString,
                Name = cs.Name,
                Type = cs.Type
            }));
            getConfigResponse.DefaultDocuments.ForEach(dd => update.DefaultDocuments.Add(dd));
            getConfigResponse.HandlerMappings.ForEach(hm => update.HandlerMappings.Add(new WebSiteUpdateConfigurationParameters.HandlerMapping
            {
                Arguments = hm.Arguments,
                Extension = hm.Extension,
                ScriptProcessor = hm.ScriptProcessor
            }));
            getConfigResponse.Metadata.ForEach(kvp => update.Metadata.Add(kvp.Key, kvp.Value));

            return update;
        }
コード例 #3
0
        public async Task <Status> Put(AppSettingsDto dto)
        {
            var client = _clientHelper.GetWebSiteClient();

            try
            {
                var settings = await client.WebSites.GetConfigurationAsync(WebSpace, Name, CancellationToken.None);

                var parameters = new WebSiteUpdateConfigurationParameters
                {
                    AppSettings       = Merge(settings.AppSettings, dto.Settings),
                    ConnectionStrings = null,
                    DefaultDocuments  = null,
                    HandlerMappings   = null,
                    Metadata          = null
                };
                var op =
                    await client.WebSites.UpdateConfigurationAsync(WebSpace, Name, parameters, CancellationToken.None);

                return((int)op.StatusCode);
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                return(500);
            }
        }
コード例 #4
0
        internal static WebSiteUpdateConfigurationParameters ToConfigUpdateParameters(this Utilities.SiteConfig config)
        {
            var parameters = new WebSiteUpdateConfigurationParameters
            {
                DetailedErrorLoggingEnabled = config.DetailedErrorLoggingEnabled,
                HttpLoggingEnabled          = config.HttpLoggingEnabled,
                NetFrameworkVersion         = config.NetFrameworkVersion,
                NumberOfWorkers             = config.NumberOfWorkers,
                PhpVersion             = config.PhpVersion,
                PublishingPassword     = config.PublishingPassword,
                PublishingUserName     = config.PublishingUsername,
                RequestTracingEnabled  = config.RequestTracingEnabled,
                ManagedPipelineMode    = config.ManagedPipelineMode,
                WebSocketsEnabled      = config.WebSocketsEnabled,
                RemoteDebuggingEnabled = config.RemoteDebuggingEnabled,
                RemoteDebuggingVersion = config.RemoteDebuggingVersion,
                RoutingRules           = config.RoutingRules.Select(r => r.ToRoutingRule()).ToArray(),
                Use32BitWorkerProcess  = config.Use32BitWorkerProcess,
            };

            if (config.AppSettings != null)
            {
                config.AppSettings.ForEach(nvp => parameters.AppSettings.Add(ToKeyValuePair(nvp)));
            }

            if (config.ConnectionStrings != null)
            {
                config.ConnectionStrings.ForEach(
                    csi => parameters.ConnectionStrings.Add(new WebSiteUpdateConfigurationParameters.ConnectionStringInfo
                {
                    Name             = csi.Name,
                    ConnectionString = csi.ConnectionString,
                    Type             = (Management.WebSites.Models.ConnectionStringType)Enum.Parse(typeof(Management.WebSites.Models.ConnectionStringType), csi.Type.ToString(), ignoreCase: true)
                }));
            }

            if (config.DefaultDocuments != null)
            {
                config.DefaultDocuments.ForEach(d => parameters.DefaultDocuments.Add(d));
            }

            if (config.HandlerMappings != null)
            {
                config.HandlerMappings.ForEach(
                    hm => parameters.HandlerMappings.Add(new WebSiteUpdateConfigurationParameters.HandlerMapping
                {
                    Arguments       = hm.Arguments,
                    Extension       = hm.Extension,
                    ScriptProcessor = hm.ScriptProcessor
                }));
            }

            if (config.Metadata != null)
            {
                config.Metadata.ForEach(nvp => parameters.Metadata.Add(ToKeyValuePair(nvp)));
            }

            return(parameters);
        }
コード例 #5
0
        public async Task SaveWebApp(WebApp app)
        {
            var connectionStrings = app.ConnectionStrings.Select(MapSettingToConnectionString).ToList();

            var newConfig = new WebSiteUpdateConfigurationParameters
            {
                ConnectionStrings = connectionStrings,
                DefaultDocuments  = null,
                HandlerMappings   = null,
                Metadata          = null,
                AppSettings       = app.AppSettings.ToDictionary(s => s.Key, s => s.Value)
            };

            using (var client = new WebSiteManagementClient(_credentials))
            {
                await client.WebSites.UpdateConfigurationAsync(app.WebSpace, app.Name, newConfig);
            }
        }
コード例 #6
0
        internal static WebSiteUpdateConfigurationParameters ToConfigUpdateParameters(this SiteConfig config)
        {
            var parameters = new WebSiteUpdateConfigurationParameters
            {
                DetailedErrorLoggingEnabled = config.DetailedErrorLoggingEnabled,
                HttpLoggingEnabled          = config.HttpLoggingEnabled,
                NetFrameworkVersion         = config.NetFrameworkVersion,
                NumberOfWorkers             = config.NumberOfWorkers,
                PhpVersion             = config.PhpVersion,
                PublishingPassword     = config.PublishingPassword,
                PublishingUserName     = config.PublishingUsername,
                RequestTracingEnabled  = config.RequestTracingEnabled,
                ManagedPipelineMode    = config.ManagedPipelineMode,
                WebSocketsEnabled      = config.WebSocketsEnabled,
                RemoteDebuggingEnabled = config.RemoteDebuggingEnabled,
                RemoteDebuggingVersion = config.RemoteDebuggingVersion
            };

            config.AppSettings.ForEach(nvp => parameters.AppSettings.Add(ToKeyValuePair(nvp)));
            config.ConnectionStrings.ForEach(
                csi => parameters.ConnectionStrings.Add(new WebSiteUpdateConfigurationParameters.ConnectionStringInfo
            {
                Name             = csi.Name,
                ConnectionString = csi.ConnectionString,
                Type             = csi.Type.ToString()
            }));

            config.DefaultDocuments.ForEach(d => parameters.DefaultDocuments.Add(d));
            config.HandlerMappings.ForEach(
                hm => parameters.HandlerMappings.Add(new WebSiteUpdateConfigurationParameters.HandlerMapping
            {
                Arguments       = hm.Arguments,
                Extension       = hm.Extension,
                ScriptProcessor = hm.ScriptProcessor
            }));

            config.Metadata.ForEach(nvp => parameters.Metadata.Add(ToKeyValuePair(nvp)));

            return(parameters);
        }
コード例 #7
0
        public void GetAndSetNonSensitiveSiteConfigs()
        {
            RunWebsiteTestScenario(
                (siteName, resourceGroupName, whpName, locationName, webSitesClient, resourcesClient) =>
            {
                #region Get/Set PythonVersion

                var configurationResponse = webSitesClient.WebSites.GetConfiguration(resourceGroupName,
                                                                                     siteName, null, new WebSiteGetConfigurationParameters());

                Assert.NotNull(configurationResponse.Resource);
                Assert.NotNull(configurationResponse.Resource.Properties);
                Assert.True(String.IsNullOrEmpty(configurationResponse.Resource.Properties.PythonVersion));

                var configurationParameters = new WebSiteUpdateConfigurationParameters
                {
                    Location   = configurationResponse.Resource.Location,
                    Properties = new WebSiteUpdateConfigurationDetails
                    {
                        PythonVersion = "3.4"
                    }
                };
                var operationResponse = webSitesClient.WebSites.UpdateConfiguration(resourceGroupName,
                                                                                    siteName, null, configurationParameters);

                Assert.Equal(HttpStatusCode.OK, operationResponse.StatusCode);

                configurationResponse = webSitesClient.WebSites.GetConfiguration(resourceGroupName,
                                                                                 siteName, null, new WebSiteGetConfigurationParameters());

                Assert.NotNull(configurationResponse.Resource);
                Assert.NotNull(configurationResponse.Resource.Properties);
                Assert.Equal(configurationResponse.Resource.Properties.PythonVersion, configurationParameters.Properties.PythonVersion);

                #endregion Get/Set PythonVersion
            });
        }
コード例 #8
0
        internal static WebSiteUpdateConfigurationParameters ToConfigUpdateParameters(this SiteConfig config)
        {
            var parameters = new WebSiteUpdateConfigurationParameters
            {
                DetailedErrorLoggingEnabled = config.DetailedErrorLoggingEnabled,
                HttpLoggingEnabled = config.HttpLoggingEnabled,
                NetFrameworkVersion = config.NetFrameworkVersion,
                NumberOfWorkers = config.NumberOfWorkers,
                PhpVersion = config.PhpVersion,
                PublishingPassword = config.PublishingPassword,
                PublishingUserName = config.PublishingUsername,
                RequestTracingEnabled = config.RequestTracingEnabled,
                ManagedPipelineMode = config.ManagedPipelineMode,
                WebSocketsEnabled = config.WebSocketsEnabled,
                RemoteDebuggingEnabled = config.RemoteDebuggingEnabled,
                RemoteDebuggingVersion = config.RemoteDebuggingVersion
            };
            config.AppSettings.ForEach(nvp => parameters.AppSettings.Add(ToKeyValuePair(nvp)));
            config.ConnectionStrings.ForEach(
                csi => parameters.ConnectionStrings.Add(new WebSiteUpdateConfigurationParameters.ConnectionStringInfo
                {
                    Name = csi.Name,
                    ConnectionString = csi.ConnectionString,
                    Type = csi.Type.ToString()
                }));

            config.DefaultDocuments.ForEach(d => parameters.DefaultDocuments.Add(d));
            config.HandlerMappings.ForEach(
                hm => parameters.HandlerMappings.Add(new WebSiteUpdateConfigurationParameters.HandlerMapping
                {
                    Arguments = hm.Arguments,
                    Extension = hm.Extension,
                    ScriptProcessor = hm.ScriptProcessor
                }));

            config.Metadata.ForEach(nvp => parameters.Metadata.Add(ToKeyValuePair(nvp)));

            return parameters;
        }
コード例 #9
0
 /// <summary>
 ///     Update website configuration
 /// </summary>
 /// <param name="webSpaceName"></param>
 /// <param name="siteName"></param>
 /// <param name="updateConfigParams"></param>
 public void UpdateWebSiteConfig(string webSpaceName, string siteName, WebSiteUpdateConfigurationParameters updateConfigParams)
 {
     TestEasyLog.Instance.Info(string.Format("Updating web site config '{0}'", siteName));
     WebSiteManagementClient.WebSites.UpdateConfigurationAsync(webSpaceName, siteName, updateConfigParams, new CancellationToken()).Wait();
 }
コード例 #10
0
 /// <summary>
 ///     Update web site configuration
 /// </summary>
 /// <param name="siteName"></param>
 /// <param name="updateConfigParams"></param>
 public void UpdateWebSiteConfig(string siteName, WebSiteUpdateConfigurationParameters updateConfigParams)
 {
     UpdateWebSiteConfig(_webSpace, siteName, updateConfigParams);
 }
        public void UpdateSiteConfig()
        {
            var handler = new RecordedDelegatingHandler()
            {
                StatusCodeToReturn = HttpStatusCode.OK
            };
            var client = GetWebSiteManagementClient(handler);

            string expectedClientId = Guid.NewGuid().ToString();
            string expectedIssuer   = "https://sts.microsoft.net/" + Guid.NewGuid() + "/";

            var expectedLimits = new WebSiteUpdateConfigurationParameters.SiteLimits()
            {
                MaxDiskSizeInMb  = 1024,
                MaxMemoryInMb    = 512,
                MaxPercentageCpu = 70.5
            };

            var parameters = new WebSiteUpdateConfigurationParameters
            {
                SiteAuthEnabled  = true,
                SiteAuthSettings = new SiteAuthSettings
                {
                    AADClientId  = expectedClientId,
                    OpenIdIssuer = expectedIssuer,
                },
                Limits = expectedLimits
            };

            // Simulate a PUT request to update the config
            client.WebSites.UpdateConfiguration("webspace", "website", parameters);

            // Check the payload of the previous request to see if it matches our expectations
            Assert.Equal(handler.Method, HttpMethod.Put);
            Assert.NotEmpty(handler.Request);
            JObject requestJson = JObject.Parse(handler.Request);

            JToken token;

            Assert.True(requestJson.TryGetValue("SiteAuthEnabled", out token));
            Assert.Equal(JTokenType.Boolean, token.Type);
            Assert.True(token.Value <bool>());

            Assert.True(requestJson.TryGetValue("SiteAuthSettings", out token));
            Assert.Equal(JTokenType.Object, token.Type);

            JObject siteAuthSettingsJson = (JObject)token;

            Assert.True(siteAuthSettingsJson.TryGetValue("AADClientId", out token));
            Assert.Equal(JTokenType.String, token.Type);
            Assert.Equal(expectedClientId, token.Value <string>());

            Assert.True(siteAuthSettingsJson.TryGetValue("OpenIdIssuer", out token));
            Assert.Equal(JTokenType.String, token.Type);
            Assert.Equal(expectedIssuer, token.Value <string>());

            Assert.True(requestJson.TryGetValue("limits", out token));
            Assert.Equal(JTokenType.Object, token.Type);
            JObject limitsJson = (JObject)token;

            Assert.True(limitsJson.TryGetValue("maxDiskSizeInMb", out token));
            Assert.Equal(JTokenType.Integer, token.Type);
            Assert.Equal(expectedLimits.MaxDiskSizeInMb, token.Value <long>());

            Assert.True(limitsJson.TryGetValue("maxMemoryInMb", out token));
            Assert.Equal(JTokenType.Integer, token.Type);
            Assert.Equal(expectedLimits.MaxMemoryInMb, token.Value <long>());

            Assert.True(limitsJson.TryGetValue("maxPercentageCpu", out token));
            Assert.Equal(JTokenType.Float, token.Type);
            Assert.Equal(expectedLimits.MaxPercentageCpu, token.Value <double>());
        }
コード例 #12
0
        public void GetAndSetSiteLimits()
        {
            var handler = new RecordedDelegatingHandler()
            {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var webSitesClient  = ResourceGroupHelper.GetWebSitesClient(handler);
                var resourcesClient = ResourceGroupHelper.GetResourcesClient(handler);

                string whpName           = TestUtilities.GenerateName("cswhp");
                string resourceGroupName = TestUtilities.GenerateName("csmrg");

                var    locationName = ResourceGroupHelper.GetResourceLocation(resourcesClient, "Microsoft.Web/sites");
                string siteName     = TestUtilities.GenerateName("csmws");

                resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroupName,
                                                              new ResourceGroup
                {
                    Location = locationName
                });

                webSitesClient.WebHostingPlans.CreateOrUpdate(resourceGroupName, new WebHostingPlanCreateOrUpdateParameters
                {
                    WebHostingPlan = new WebHostingPlan
                    {
                        Name       = whpName,
                        Location   = locationName,
                        Properties = new WebHostingPlanProperties
                        {
                            NumberOfWorkers = 1,
                            WorkerSize      = WorkerSizeOptions.Small
                        }
                    }
                });

                var createResponse = webSitesClient.WebSites.CreateOrUpdate(resourceGroupName, siteName, null, new WebSiteCreateOrUpdateParameters()
                {
                    WebSite = new WebSiteBase()
                    {
                        Name       = siteName,
                        Location   = locationName,
                        Properties = new WebSiteBaseProperties()
                        {
                            ServerFarm = whpName
                        }
                    }
                });

                #region Get/Set Site limits

                var expectedSitelimits = new SiteLimits()
                {
                    MaxDiskSizeInMb  = 512,
                    MaxMemoryInMb    = 1024,
                    MaxPercentageCpu = 70.5
                };
                var parameters = new WebSiteUpdateConfigurationParameters()
                {
                    Location   = locationName,
                    Properties = new WebSiteUpdateConfigurationDetails()
                    {
                        Limits = expectedSitelimits
                    }
                };


                var siteUpdateConfigResponse = webSitesClient.WebSites.UpdateConfiguration(
                    resourceGroupName,
                    siteName,
                    null,
                    parameters);

                Assert.Equal(HttpStatusCode.OK, siteUpdateConfigResponse.StatusCode);

                var siteGetConfigResponse = webSitesClient.WebSites.GetConfiguration(resourceGroupName,
                                                                                     siteName, null, null);

                Assert.NotNull(siteGetConfigResponse);
                Assert.NotNull(siteGetConfigResponse.Resource);
                Assert.NotNull(siteGetConfigResponse.Resource.Properties);
                var limits = siteGetConfigResponse.Resource.Properties.Limits;
                Assert.NotNull(limits);
                Assert.Equal(expectedSitelimits.MaxDiskSizeInMb, limits.MaxDiskSizeInMb);
                Assert.Equal(expectedSitelimits.MaxMemoryInMb, limits.MaxMemoryInMb);
                Assert.Equal(expectedSitelimits.MaxPercentageCpu, limits.MaxPercentageCpu);

                #endregion Get/Set Site limits

                webSitesClient.WebSites.Delete(resourceGroupName, siteName, null, new WebSiteDeleteParameters()
                {
                    DeleteAllSlots = true,
                    DeleteMetrics  = true
                });

                webSitesClient.WebHostingPlans.Delete(resourceGroupName, whpName);
            }
        }
コード例 #13
0
 /// <summary>
 /// You can retrieve the config settings for a web site by issuing an
 /// HTTP GET request, or update them by using HTTP PUT with a request
 /// body that contains the settings to be updated.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.WebSites.IWebSiteOperations.
 /// </param>
 /// <param name='webSpaceName'>
 /// The name of the web space.
 /// </param>
 /// <param name='webSiteName'>
 /// The name of the web site.
 /// </param>
 /// <param name='parameters'>
 /// The Update Web Site Configuration parameters.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static Task <OperationResponse> UpdateConfigurationAsync(this IWebSiteOperations operations, string webSpaceName, string webSiteName, WebSiteUpdateConfigurationParameters parameters)
 {
     return(operations.UpdateConfigurationAsync(webSpaceName, webSiteName, parameters, CancellationToken.None));
 }
コード例 #14
0
 /// <summary>
 /// You can retrieve the config settings for a web site by issuing an
 /// HTTP GET request, or update them by using HTTP PUT with a request
 /// body that contains the settings to be updated.  (see
 /// http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.WebSites.IWebSiteOperations.
 /// </param>
 /// <param name='webSpaceName'>
 /// The name of the web space.
 /// </param>
 /// <param name='webSiteName'>
 /// The name of the web site.
 /// </param>
 /// <param name='parameters'>
 /// The Update Web Site Configuration parameters.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static OperationResponse UpdateConfiguration(this IWebSiteOperations operations, string webSpaceName, string webSiteName, WebSiteUpdateConfigurationParameters parameters)
 {
     try
     {
         return(operations.UpdateConfigurationAsync(webSpaceName, webSiteName, parameters).Result);
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count > 1)
         {
             throw;
         }
         else
         {
             throw ex.InnerException;
         }
     }
 }
コード例 #15
0
        static async Task CreateSite(string rgName, string whpName, string siteName, string location)
        {
            // Create/Update the resource group
            var rgCreateResult = await _resourceGroupClient.ResourceGroups.CreateOrUpdateAsync(rgName, new ResourceGroup { Location = location });

            // Create/Update the Web Hosting Plan
            var whpCreateParams = new WebHostingPlanCreateOrUpdateParameters
            {
                WebHostingPlan = new WebHostingPlan
                {
                    Name       = whpName,
                    Location   = location,
                    Properties = new WebHostingPlanProperties
                    {
                        Sku = SkuOptions.Free
                    }
                }
            };
            var whpCreateResult = await _websiteClient.WebHostingPlans.CreateOrUpdateAsync(rgName, whpCreateParams);

            // Create/Update the Website
            var createParams = new WebSiteCreateOrUpdateParameters
            {
                WebSite = new WebSiteBase
                {
                    Name       = siteName,
                    Location   = location,
                    Properties = new WebSiteBaseProperties
                    {
                        ServerFarm = whpName
                    }
                }
            };
            var siteCreateResult = await _websiteClient.WebSites.CreateOrUpdateAsync(rgName, siteName, null /*slot*/, createParams);

            // Create/Update the Website configuration
            var siteUpdateParams = new WebSiteUpdateConfigurationParameters
            {
                Location   = location,
                Properties = new WebSiteUpdateConfigurationDetails
                {
                    PhpVersion = "5.6",
                }
            };
            var siteUpdateRes = await _websiteClient.WebSites.UpdateConfigurationAsync(rgName, siteName, null /*slot*/, siteUpdateParams);

            // List current App Settings
            var appSettingsRes = await _websiteClient.WebSites.GetAppSettingsAsync(rgName, siteName, null /*slot*/);

            foreach (var appSetting in appSettingsRes.Resource.Properties)
            {
                Console.WriteLine("{0} = {1}", appSetting.Name, appSetting.Value);
            }

            // Create/Update some App Settings
            var appSettingsParams = new WebSiteNameValueParameters
            {
                Location   = location,
                Properties = new List <NameValuePair>
                {
                    new NameValuePair {
                        Name = "MyFirstKey", Value = "My first value"
                    },
                    new NameValuePair {
                        Name = "MySecondKey", Value = "My second value"
                    }
                }
            };

            appSettingsRes = await _websiteClient.WebSites.UpdateAppSettingsAsync(rgName, siteName, null /*slot*/, appSettingsParams);

            // Create/Update some Connection Strings
            var connStringsParams = new WebSiteUpdateConnectionStringsParameters
            {
                Location   = location,
                Properties = new List <ConnectionStringInfo>
                {
                    new ConnectionStringInfo {
                        Name = "MyFirstConnString", ConnectionString = "My SQL conn string", Type = DatabaseServerType.SQLAzure
                    },
                    new ConnectionStringInfo {
                        Name = "MySecondConnString", ConnectionString = "My custom conn string", Type = DatabaseServerType.Custom
                    }
                }
            };
            var connStringsRes = await _websiteClient.WebSites.UpdateConnectionStringsAsync(rgName, siteName, null /*slot*/, connStringsParams);
        }
コード例 #16
0
 /// <summary>
 /// You can update the config settings for a web site by issuing an
 /// HTTP PUT with a request body containing the updated settings.
 /// (see http://msdn.microsoft.com/en-us/library/windowsazure/dn166985.aspx
 /// for more information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.WebSites.IWebSiteOperations.
 /// </param>
 /// <param name='webSpaceName'>
 /// Required. The name of the web space.
 /// </param>
 /// <param name='webSiteName'>
 /// Required. The name of the web site.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters supplied to the Update Configuration Web Site
 /// operation.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static OperationResponse UpdateConfiguration(this IWebSiteOperations operations, string webSpaceName, string webSiteName, WebSiteUpdateConfigurationParameters parameters)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IWebSiteOperations)s).UpdateConfigurationAsync(webSpaceName, webSiteName, parameters);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }