public async Task <AppServicePlanInner> CreateAppServicePlanAsync( IResourceGroup resourceGroup, string appServicePlanName, IDictionary <string, string> tags = null, CancellationToken cancellationToken = default ) { try { tags ??= new Dictionary <string, string>(); Log.Information($"Creating Azure AppService Plan: {appServicePlanName} ..."); var appServicePlanParameters = new AppServicePlanInner { Location = resourceGroup.RegionName, Tags = tags, Sku = new SkuDescription { Name = "S1", Capacity = 0 } }; appServicePlanParameters.Validate(); var appServicePlan = await _webSiteManagementClient .AppServicePlans .CreateOrUpdateAsync( resourceGroup.Name, appServicePlanName, appServicePlanParameters, cancellationToken ); Log.Information($"Created Azure AppService Plan: {appServicePlanName}"); return(appServicePlan); } catch (Exception ex) { Log.Error(ex, $"Failed to create Azure AppService Plan: {appServicePlanName}"); throw; } }
public async Task <SiteInner> CreateSiteAsync( IResourceGroup resourceGroup, AppServicePlanInner appServicePlan, string azureWebsiteName, string remoteEndpoint, X509Certificate2 webAppX509Certificate, IDictionary <string, string> tags = null, CancellationToken cancellationToken = default ) { try { tags ??= new Dictionary <string, string>(); Log.Information($"Creating Azure AppService: {azureWebsiteName} ..."); var webSiteParameters = new SiteInner { Location = resourceGroup.RegionName, Tags = tags, Enabled = true, HttpsOnly = true, // Will redirect HTTP traffic to HTTPS. ClientAffinityEnabled = false, ServerFarmId = appServicePlan.Id, SiteConfig = new SiteConfig { AppSettings = new List <NameValuePair> { new NameValuePair { Name = PROXY_ENV_REMOTE_ENDPOINT, // NOTE: This should be Public IP address exposed by Ingress. Value = remoteEndpoint }, new NameValuePair { Name = PROXY_ENV_REMOTE_ENDPOINT_SSL_THUMBPRINT, // NOTE: this certificate should be added to Ingress as default certificate. Value = webAppX509Certificate.Thumbprint } }, // Coming from Microsoft.Web/sites/config resource NumberOfWorkers = 1, RequestTracingEnabled = true, HttpLoggingEnabled = true, DetailedErrorLoggingEnabled = true, AlwaysOn = true, MinTlsVersion = SupportedTlsVersions.OneFullStopTwo } }; webSiteParameters.Validate(); var webSite = await _webSiteManagementClient .WebApps .CreateOrUpdateAsync( resourceGroup.Name, azureWebsiteName, webSiteParameters, cancellationToken ); Log.Information($"Created Azure AppService: {azureWebsiteName}"); return(webSite); } catch (Exception ex) { Log.Error(ex, $"Failed to create Azure AppService: {azureWebsiteName}"); throw; } }
/// <summary> /// Creates or updates an App Service Plan. /// </summary> /// <remarks> /// Creates or updates an App Service Plan. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of the resource group to which the resource belongs. /// </param> /// <param name='name'> /// Name of the App Service plan. /// </param> /// <param name='appServicePlan'> /// Details of the App Service plan. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <AppServicePlanInner> BeginCreateOrUpdateAsync(this IAppServicePlansOperations operations, string resourceGroupName, string name, AppServicePlanInner appServicePlan, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, name, appServicePlan, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }