/// <summary> /// You can retrieve the metadata 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.Azure.Management.WebSites.IWebSiteOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the resource group /// </param> /// <param name='webSiteName'> /// Required. The name of the website /// </param> /// <param name='slotName'> /// Optional. The name of the slot of the website /// </param> /// <param name='parameters'> /// Required. The Update Web Site metadata parameters /// </param> /// <returns> /// List of metadata for the website. /// </returns> public static WebSiteMetadataResult UpdateMetadata(this IWebSiteOperations operations, string resourceGroupName, string webSiteName, string slotName, WebSiteNameValueParameters parameters) { return Task.Factory.StartNew((object s) => { return ((IWebSiteOperations)s).UpdateMetadataAsync(resourceGroupName, webSiteName, slotName, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
/// <summary> /// You can retrieve the metadata 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.Azure.Management.WebSites.IWebSiteOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the resource group /// </param> /// <param name='webSiteName'> /// Required. The name of the website /// </param> /// <param name='slotName'> /// Optional. The name of the slot of the website /// </param> /// <param name='parameters'> /// Required. The Update Web Site metadata parameters /// </param> /// <returns> /// List of metadata for the website. /// </returns> public static Task<WebSiteMetadataResult> UpdateMetadataAsync(this IWebSiteOperations operations, string resourceGroupName, string webSiteName, string slotName, WebSiteNameValueParameters parameters) { return operations.UpdateMetadataAsync(resourceGroupName, webSiteName, slotName, parameters, CancellationToken.None); }
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); }