示例#1
0
        ///GENMHASH:DBC91E274023CE112BF5317D36B0BDC3:08D6495FD781CCB57E524CE9B1EDE729

        internal WebAppSourceControlImpl(
            SiteSourceControlInner inner,
            WebAppBaseImpl <FluentT, FluentImplT, DefAfterRegionT, DefAfterGroupT, UpdateT> parent)
            : base(inner)
        {
            this.parent = parent;
        }
示例#2
0
        /// <summary>
        /// Deploy lightweight reverse proxy to App Service.
        /// </summary>
        /// <param name="resourceGroup"></param>
        /// <param name="webSite"></param>
        /// <param name="tags"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <SiteSourceControlInner> DeployProxyAsync(
            IResourceGroup resourceGroup,
            SiteInner webSite,
            IDictionary <string, string> tags   = null,
            CancellationToken cancellationToken = default
            )
        {
            try {
                tags ??= new Dictionary <string, string>();

                Log.Information($"Deploying proxy service to AppService: {webSite.Name} ...");

                var siteSourceControlDefinition = new SiteSourceControlInner()
                {
                    Location = resourceGroup.RegionName,
                    Tags     = tags,

                    RepoUrl             = PROXY_REPO_URL,
                    Branch              = PROXY_BRANCH,
                    IsManualIntegration = true
                };

                siteSourceControlDefinition.Validate();

                var siteSourceControl = await _webSiteManagementClient
                                        .WebApps
                                        .CreateOrUpdateSourceControlAsync(
                    resourceGroup.Name,
                    webSite.Name,
                    siteSourceControlDefinition,
                    cancellationToken
                    );

                Log.Information($"Deployed proxy service to AppService: {webSite.Name}");

                return(siteSourceControl);
            }
            catch (Exception ex) {
                Log.Error(ex, $"Failed deploy proxy service to AppService: {webSite.Name}");
                throw;
            }
        }
 ///GENMHASH:88806945F575AAA522C2E09EBC366CC0:648365CFF3D36F6215B51C13E63240EA
 internal override async Task <Models.SiteSourceControlInner> CreateOrUpdateSourceControlAsync(SiteSourceControlInner inner, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await Manager.Inner.WebApps.CreateOrUpdateSourceControlSlotAsync(ResourceGroupName, parent.Name, inner, Name, cancellationToken));
 }
示例#4
0
        ///GENMHASH:88806945F575AAA522C2E09EBC366CC0:FDA787AD964B4EF34BCD2352730B6528

        internal async override Task <SiteSourceControlInner> CreateOrUpdateSourceControlAsync(SiteSourceControlInner inner, CancellationToken cancellationToken = default(CancellationToken))
        {
            return(await Manager.Inner.WebApps.CreateOrUpdateSourceControlAsync(ResourceGroupName, Name, inner, cancellationToken));
        }
示例#5
0
        ///GENMHASH:BC96AA8FDB678157AC1E6F0AA511AB65:20A70C4EEFBA9DE9AD6AA6D9133187D7
        public override IWebAppSourceControl GetSourceControl()
        {
            SiteSourceControlInner siteSourceControlInner = Extensions.Synchronize(() => Manager.Inner.WebApps.GetSourceControlAsync(ResourceGroupName, Name));

            return(new WebAppSourceControlImpl <FluentT, FluentImplT, DefAfterRegionT, DefAfterGroupT, UpdateT>(siteSourceControlInner, (FluentImplT)this));
        }
示例#6
0
        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 = 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 PublicIP 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
                    );

                var siteSourceControlRequest = new SiteSourceControlInner()
                {
                    Location = resourceGroup.RegionName,
                    Tags     = tags,

                    RepoUrl             = PROXY_REPO_URL,
                    Branch              = PROXY_BRANCH,
                    IsManualIntegration = true
                };

                siteSourceControlRequest.Validate();

                var siteSourceControl = await _webSiteManagementClient
                                        .WebApps
                                        .CreateOrUpdateSourceControlAsync(
                    resourceGroup.Name,
                    azureWebsiteName,
                    siteSourceControlRequest,
                    cancellationToken
                    );

                webSite = await _webSiteManagementClient
                          .WebApps
                          .GetAsync(
                    resourceGroup.Name,
                    azureWebsiteName,
                    cancellationToken
                    );

                Log.Information($"Created Azure AppService: {azureWebsiteName}");

                return(webSite);
            }
            catch (Exception ex) {
                Log.Error(ex, $"Failed to create Azure AppService: {azureWebsiteName}");
                throw;
            }
        }