コード例 #1
0
        /// <summary>
        /// Initialize VM's identity property.
        /// </summary>
        /// <param name="identityType">The identity type to set.</param>
        private void InitSiteIdentity(ManagedServiceIdentityType identityType)
        {
            if (!identityType.Equals(ManagedServiceIdentityType.UserAssigned) &&
                !identityType.Equals(ManagedServiceIdentityType.SystemAssigned))
            {
                throw new ArgumentException("Invalid argument: " + identityType);
            }

            SiteInner siteInner = this.webAppBaseImpl.Inner;

            if (siteInner.Identity == null)
            {
                siteInner.Identity = new ManagedServiceIdentity();
            }

            if (siteInner.Identity.Type == null ||
                siteInner.Identity.Type.Equals(ManagedServiceIdentityType.None) ||
                siteInner.Identity.Type.Equals(identityType))
            {
                siteInner.Identity.Type = identityType;
            }
            else
            {
                siteInner.Identity.Type = ManagedServiceIdentityType.SystemAssignedUserAssigned;
            }
        }
コード例 #2
0
        internal override async Task <Models.SiteInner> SubmitAppSettingsAsync(SiteInner site, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (storageAccountCreatable != null && CreatedResource(storageAccountCreatable.Key) != null)
            {
                storageAccountToSet = (IStorageAccount)CreatedResource(storageAccountCreatable.Key);
            }
            if (storageAccountToSet == null)
            {
                return(await base.SubmitAppSettingsAsync(site, cancellationToken));
            }
            else
            {
                var keys = await storageAccountToSet.GetKeysAsync(cancellationToken);

                var connectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}",
                                                     storageAccountToSet.Name, keys[0].Value);
                WithAppSetting("AzureWebJobsStorage", connectionString);
                WithAppSetting("AzureWebJobsDashboard", connectionString);
                WithAppSetting("WEBSITE_CONTENTAZUREFILECONNECTIONSTRING", connectionString);
                WithAppSetting("WEBSITE_CONTENTSHARE", SdkContext.RandomResourceName(Name, 32));

                // clean up
                currentStorageAccount   = storageAccountToSet;
                storageAccountToSet     = null;
                storageAccountCreatable = null;

                return(await base.SubmitAppSettingsAsync(site, cancellationToken));
            }
        }
コード例 #3
0
        internal override async Task <Models.SiteInner> SubmitAppSettingsAsync(SiteInner site, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (storageAccountCreatable != null && CreatedResource(storageAccountCreatable.Key) != null)
            {
                storageAccountToSet = (IStorageAccount)CreatedResource(storageAccountCreatable.Key);
            }
            if (storageAccountToSet == null)
            {
                return(await base.SubmitAppSettingsAsync(site, cancellationToken));
            }
            else
            {
                AzureEnvironment environment    = ResourceUtils.ExtractAzureEnvironment(Manager.RestClient) ?? AzureEnvironment.AzureGlobalCloud;
                string           endpointSuffix = Regex.Replace(environment.StorageEndpointSuffix ?? AzureEnvironment.AzureGlobalCloud.StorageEndpointSuffix, "^\\.*", "");
                var servicePlanTask             = Manager.AppServicePlans.GetByIdAsync(this.AppServicePlanId());
                var keys = await storageAccountToSet.GetKeysAsync(cancellationToken);

                var connectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};EndpointSuffix={2}",
                                                     storageAccountToSet.Name, keys[0].Value, endpointSuffix);
                AddAppSettingIfNotModified("AzureWebJobsStorage", connectionString);
                AddAppSettingIfNotModified("AzureWebJobsDashboard", connectionString);
                if (IsConsumptionAppServicePlan((await servicePlanTask)?.PricingTier))
                {
                    AddAppSettingIfNotModified("WEBSITE_CONTENTAZUREFILECONNECTIONSTRING", connectionString);
                    AddAppSettingIfNotModified("WEBSITE_CONTENTSHARE", SdkContext.RandomResourceName(Name, 32));
                }

                // clean up
                currentStorageAccount   = storageAccountToSet;
                storageAccountToSet     = null;
                storageAccountCreatable = null;

                return(await base.SubmitAppSettingsAsync(site, cancellationToken));
            }
        }
コード例 #4
0
 private IWebApp WrapModel(SiteInner inner, SiteConfigResourceInner siteConfigInner)
 {
     if (inner == null)
     {
         return(null);
     }
     return(new WebAppImpl(inner.Name, inner, siteConfigInner, Manager));
 }
コード例 #5
0
        private async Task <IWebApp> PopulateModelAsync(SiteInner inner, CancellationToken cancellationToken = default(CancellationToken))
        {
            var siteConfig = await Inner.GetConfigurationAsync(inner.ResourceGroup, inner.Name, cancellationToken);

            var webApp = WrapModel(inner, siteConfig);

            return(webApp);
        }
コード例 #6
0
 private IFunctionApp WrapModel(SiteInner inner, SiteConfigResourceInner siteConfigInner, SiteLogsConfigInner logsConfigInner)
 {
     if (inner == null)
     {
         return(null);
     }
     return(new FunctionAppImpl(inner.Name, inner, siteConfigInner, logsConfigInner, Manager));
 }
コード例 #7
0
 ///GENMHASH:64609469010BC4A501B1C3197AE4F243:BEC51BB7FA5CB1F04F04C62A207332AE
 protected override IFunctionApp WrapModel(SiteInner inner)
 {
     if (inner == null)
     {
         return(null);
     }
     return(new FunctionAppImpl(inner.Name, inner, null, null, Manager));
 }
コード例 #8
0
 ///GENMHASH:B22FA99F4432342EBBDB2AB426A8D2A2:DB92CE96AE133E965FE6DE31D475D7ED
 internal AppServiceBaseImpl(
     string name,
     SiteInner innerObject,
     SiteConfigResourceInner configObject,
     IAppServiceManager manager)
     : base(name, innerObject, configObject, manager)
 {
 }
コード例 #9
0
        internal void HandleExternalIdentities()
        {
            SiteInner siteInner = (SiteInner)this.webAppBaseImpl.Inner;

            if (this.userAssignedIdentities.Any())
            {
                siteInner.Identity.UserAssignedIdentities = this.userAssignedIdentities;
            }
        }
コード例 #10
0
        private async Task <IFunctionApp> PopulateModelAsync(SiteInner inner, CancellationToken cancellationToken = default(CancellationToken))
        {
            var siteConfig = await Inner.GetConfigurationAsync(inner.ResourceGroup, inner.Name, cancellationToken);

            var FunctionApp = WrapModel(inner, siteConfig);

            await((FunctionAppImpl)FunctionApp).CacheSiteProperties(cancellationToken);
            return(FunctionApp);
        }
コード例 #11
0
 ///GENMHASH:B22FA99F4432342EBBDB2AB426A8D2A2:DB92CE96AE133E965FE6DE31D475D7ED
 internal WebAppImpl(
     string name,
     SiteInner innerObject,
     SiteConfigResourceInner configObject,
     IAppServiceManager manager)
     : base(name, innerObject, configObject, manager)
 {
     kuduClient = new KuduClient(this);
 }
コード例 #12
0
        private async Task <IFunctionApp> PopulateModelAsync(SiteInner inner, CancellationToken cancellationToken = default(CancellationToken))
        {
            var siteConfig = await Inner.GetConfigurationAsync(inner.ResourceGroup, inner.Name, cancellationToken);

            var logConfig = await Inner.GetDiagnosticLogsConfigurationAsync(inner.ResourceGroup, inner.Name, cancellationToken);

            var FunctionApp = WrapModel(inner, siteConfig, logConfig);

            return(FunctionApp);
        }
        ///GENMHASH:7165E4A72787EF020E1C59029B4D2D13:A0244A057D0D2A3944D2A1B6B5FC52D6

        internal DeploymentSlotImpl(
            string name,
            SiteInner innerObject,
            SiteConfigResourceInner configObject,
            WebAppImpl parent,
            IAppServiceManager manager)
            : base(Regex.Replace(name, ".*/", ""), innerObject, configObject, manager)
        {
            this.name          = Regex.Replace(name, ".*/", "");
            this.parent        = parent;
            Inner.ServerFarmId = parent.AppServicePlanId();
        }
コード例 #14
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;
            }
        }
コード例 #15
0
        ///GENMHASH:D9CEBC2EF6EA60751F2BFE78FE5E22B3:86C919F4CA67F8BA602AC70FD7CCC9E0
        internal override async Task <Models.SiteInner> SubmitConnectionStringsAsync(SiteInner site, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (configurationSource == null || !IsInCreateMode)
            {
                return(await base.SubmitConnectionStringsAsync(site, cancellationToken));
            }

            foreach (IConnectionString conn in (await configurationSource.GetConnectionStringsAsync(cancellationToken)).Values)
            {
                if (conn.Sticky)
                {
                    WithStickyConnectionString(conn.Name, conn.Value, conn.Type);
                }
                else
                {
                    WithConnectionString(conn.Name, conn.Value, conn.Type);
                }
            }
            return(await base.SubmitConnectionStringsAsync(Inner, cancellationToken));
        }
コード例 #16
0
        ///GENMHASH:CB483EFD6E3479A51A8504AF23852854:6313AA480AD6478F672504A1348DE17E
        internal override async Task <Models.SiteInner> SubmitAppSettingsAsync(SiteInner site, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (configurationSource == null || !IsInCreateMode)
            {
                return(await base.SubmitAppSettingsAsync(site, cancellationToken));
            }

            foreach (IAppSetting appSetting in (await configurationSource.GetAppSettingsAsync(cancellationToken)).Values)
            {
                if (appSetting.Sticky)
                {
                    WithStickyAppSetting(appSetting.Key, appSetting.Value);
                }
                else
                {
                    WithAppSetting(appSetting.Key, appSetting.Value);
                }
            }
            return(await base.SubmitAppSettingsAsync(Inner, cancellationToken));
        }
コード例 #17
0
 internal void HandleExternalIdentities(SitePatchResource siteUpdate)
 {
     if (this.HandleRemoveAllExternalIdentitiesCase(siteUpdate))
     {
         return;
     }
     else
     {
         // At this point one of the following condition is met:
         //
         // 1. User don't want touch the 'Site.Identity.UserAssignedIdentities' property
         //      [this.userAssignedIdentities.Empty() == true]
         // 2. User want to add some identities to 'Site.Identity.UserAssignedIdentities'
         //      [this.userAssignedIdentities.Empty() == false and this.webAppBase.Inner().Identity() != null]
         // 3. User want to remove some (not all) identities in 'Site.Identity.UserAssignedIdentities'
         //      [this.userAssignedIdentities.Empty() == false and this.webAppBase.Inner().Identity() != null]
         //      Note: The scenario where this.webAppBase.Inner().Identity() is null in #3 is already handled in
         //      handleRemoveAllExternalIdentitiesCase method
         // 4. User want to add and remove (all or subset) some identities in 'Site.Identity.UserAssignedIdentities'
         //      [this.userAssignedIdentities.Empty() == false and this.webAppBase.Inner().Identity() != null]
         //
         SiteInner siteInner = this.webAppBaseImpl.Inner;
         ManagedServiceIdentity currentIdentity = siteInner.Identity;
         siteUpdate.Identity = currentIdentity;
         if (this.userAssignedIdentities.Any())
         {
             // At this point its guaranteed that 'currentIdentity' is not null so vmUpdate.Identity() is.
             siteUpdate.Identity.UserAssignedIdentities = this.userAssignedIdentities;
         }
         else
         {
             // User don't want to touch 'VM.Identity.UserAssignedIdentities' property
             if (currentIdentity != null)
             {
                 // and currently there is identity exists or user want to manipulate some other properties of
                 // identity, set identities to null so that it won't send over wire.
                 currentIdentity.UserAssignedIdentities = null;
             }
         }
     }
 }
コード例 #18
0
        /// <summary>
        /// Specifies that Local Managed Service Identity needs to be disabled in the web app.
        /// </summary>
        /// <return>WebAppMsiHandler.</return>
        internal WebAppMsiHandler <FluentT, FluentImplT, DefAfterRegionT, DefAfterGroupT, UpdateT> WithoutLocalManagedServiceIdentity()
        {
            SiteInner siteInner = (SiteInner)this.webAppBaseImpl.Inner;

            if (siteInner.Identity == null ||
                siteInner.Identity.Type == null ||
                siteInner.Identity.Type.Equals(ManagedServiceIdentityType.None) ||
                siteInner.Identity.Type.Equals(ManagedServiceIdentityType.UserAssigned))
            {
                return(this);
            }
            else if (siteInner.Identity.Type.Equals(ManagedServiceIdentityType.SystemAssigned))
            {
                siteInner.Identity.Type = ManagedServiceIdentityType.None;
            }
            else if (siteInner.Identity.Type.Equals(ManagedServiceIdentityType.SystemAssignedUserAssigned))
            {
                siteInner.Identity.Type = ManagedServiceIdentityType.UserAssigned;
            }
            return(this);
        }
コード例 #19
0
        internal override async Task <SiteInner> SubmitMetadataAsync(SiteInner site, CancellationToken cancellationToken)
        {
            await base.SubmitMetadataAsync(site, cancellationToken);

            if (runtimeStackOnWindowsOSToUpdate != null)
            {
                // list metadata
                StringDictionaryInner metadataInner = await ListMetadataAsync(cancellationToken);

                // merge with change
                metadataInner            = metadataInner ?? new StringDictionaryInner();
                metadataInner.Properties = metadataInner.Properties ?? new Dictionary <string, string>();
                metadataInner.Properties["CURRENT_STACK"] = runtimeStackOnWindowsOSToUpdate.Runtime;
                // update metadata
                await UpdateMetadataAsync(metadataInner);

                // clean up
                runtimeStackOnWindowsOSToUpdate = null;
            }
            return(site);
        }
コード例 #20
0
        /// <summary>
        /// Update application settings of App Service.
        /// </summary>
        /// <param name="resourceGroup"></param>
        /// <param name="webSite"></param>
        /// <param name="remoteEndpoint"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task UpdateSiteApplicationSettingsAsync(
            IResourceGroup resourceGroup,
            SiteInner webSite,
            string remoteEndpoint,
            X509Certificate2 webAppX509Certificate,
            CancellationToken cancellationToken = default
            )
        {
            try {
                var remoteEndpointSettings = new StringDictionaryInner {
                    Location = webSite.Location,

                    Properties = new Dictionary <string, string> {
                        { PROXY_ENV_REMOTE_ENDPOINT, remoteEndpoint },
                        { PROXY_ENV_REMOTE_ENDPOINT_SSL_THUMBPRINT, webAppX509Certificate.Thumbprint }
                    }
                };

                remoteEndpointSettings.Validate();

                // Note: UpdateApplicationSettingsAsync(...) replaces existing
                // settings with new ones.
                var applicationSettings = await _webSiteManagementClient
                                          .WebApps
                                          .UpdateApplicationSettingsAsync(
                    resourceGroup.Name,
                    webSite.Name,
                    remoteEndpointSettings,
                    cancellationToken
                    );
            }
            catch (Exception ex) {
                Log.Error(ex, $"Failed to update {PROXY_ENV_REMOTE_ENDPOINT} setting of Azure AppService: {webSite.Name}");
                throw;
            }
        }
コード例 #21
0
 ///GENMHASH:07FBC6D492A2E1E463B39D4D7FFC40E9:6015327ABEB713972CA126D7A0F3C232
 internal override async Task <Models.SiteInner> CreateOrUpdateInnerAsync(SiteInner site, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await Manager.Inner.WebApps.CreateOrUpdateSlotAsync(ResourceGroupName, parent.Name, site, Name, cancellationToken : cancellationToken));
 }
コード例 #22
0
 public DeploymentSlotImpl(string name, SiteInner innerObject, SiteConfigResourceInner configObject,
                           SiteLogsConfigInner logConfig, WebAppImpl parent, IAppServiceManager manager)
     : base(name, innerObject, configObject, logConfig, parent, manager)
 {
     kuduClient = new KuduClient(this);
 }
コード例 #23
0
        /// <summary>
        /// Method that handle the case where user request indicates all it want to do is remove all identities associated
        /// with the virtual machine.
        /// </summary>
        /// <param name="siteUpdate">The vm update payload model.</param>
        /// <return>True if user indented to remove all the identities.</return>
        private bool HandleRemoveAllExternalIdentitiesCase(SitePatchResource siteUpdate)
        {
            SiteInner siteInner = (SiteInner)this.webAppBaseImpl.Inner;

            if (this.userAssignedIdentities.Any())
            {
                int rmCount = 0;
                foreach (var v in this.userAssignedIdentities.Values)
                {
                    if (v == null)
                    {
                        rmCount++;
                    }
                    else
                    {
                        break;
                    }
                }

                bool containsRemoveOnly = rmCount > 0 && rmCount == this.userAssignedIdentities.Count;
                // Check if user request contains only request for removal of identities.
                if (containsRemoveOnly)
                {
                    HashSet <string>       currentIds      = new HashSet <string>();
                    ManagedServiceIdentity currentIdentity = siteInner.Identity;
                    if (currentIdentity != null && currentIdentity.UserAssignedIdentities != null)
                    {
                        foreach (String id in currentIdentity.UserAssignedIdentities.Keys)
                        {
                            currentIds.Add(id.ToLower());
                        }
                    }
                    HashSet <string> removeIds = new HashSet <string>();
                    foreach (var entrySet in this.userAssignedIdentities)
                    {
                        if (entrySet.Value == null)
                        {
                            removeIds.Add(entrySet.Key.ToLower());
                        }
                    }


                    var removeAllCurrentIds = currentIds.Count == removeIds.Count && !removeIds.Any(id => !currentIds.Contains(id)); // Java part looks like this -> && currentIds.ContainsAll(removeIds);
                    if (removeAllCurrentIds)
                    {
                        // If so adjust  the identity type [Setting type to SYSTEM_ASSIGNED orNONE will remove all the identities]
                        if (currentIdentity == null || currentIdentity.Type == null)
                        {
                            siteUpdate.Identity = new ManagedServiceIdentity()
                            {
                                Type = ManagedServiceIdentityType.None
                            };
                        }
                        else if (currentIdentity.Type.Equals(ManagedServiceIdentityType.SystemAssigned))
                        {
                            siteUpdate.Identity      = currentIdentity;
                            siteUpdate.Identity.Type = ManagedServiceIdentityType.SystemAssigned;
                        }
                        else if (currentIdentity.Type.Equals(ManagedServiceIdentityType.UserAssigned))
                        {
                            siteUpdate.Identity      = currentIdentity;
                            siteUpdate.Identity.Type = ManagedServiceIdentityType.None;
                        }
                        // and set identities property in the payload model to null so that it won't be sent
                        siteUpdate.Identity.UserAssignedIdentities = null;
                        return(true);
                    }
                    else
                    {
                        // Check user is asking to remove identities though there is no identities currently associated
                        if (currentIds.Count == 0 &&
                            removeIds.Count != 0 &&
                            currentIdentity == null)
                        {
                            // If so we are in a invalid state but we want to send user input to service and let service
                            // handle it (ignore or error).
                            siteUpdate.Identity = new ManagedServiceIdentity()
                            {
                                Type = ManagedServiceIdentityType.None,
                                UserAssignedIdentities = null
                            };
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
コード例 #24
0
 internal FunctionAppImpl(string name, SiteInner innerObject, SiteConfigResourceInner configObject,
                          SiteLogsConfigInner logConfig, IAppServiceManager manager)
     : base(name, innerObject, configObject, logConfig, manager)
 {
     functionCredentials = new FunctionCredentials(this);
 }
コード例 #25
0
 internal FunctionAppImpl(string name, SiteInner innerObject, SiteConfigResourceInner configObject, IAppServiceManager manager)
     : base(name, innerObject, configObject, manager)
 {
     kuduCredentials = new KuduCredentials(this);
 }
コード例 #26
0
        public IIoTEnvironment(
            AzureEnvironment azureEnvironment,
            Guid tenantId,
            IotHubDescription iotHub,
            string iotHubOwnerConnectionString,
            string iotHubOnboardingConsumerGroupName,
            int iotHubEventHubEndpointsPartitionsCount,
            string cosmosDBAccountConnectionString,
            StorageAccountInner storageAccount,
            StorageAccountKey storageAccountKey,
            EventhubInner eventHub,
            string eventHubConnectionString,
            string serviceBusConnectionString,
            string signalRConnectionString,
            VaultInner keyVault,
            Workspace operationalInsightsWorkspace,
            ApplicationInsightsComponent applicationInsightsComponent,
            SiteInner webSite,
            Application serviceApplication,
            Application clientApplication

            )
        {
            _HUB_CS = iotHubOwnerConnectionString;

            PCS_IOTHUB_CONNSTRING = iotHubOwnerConnectionString;                        // duplicate
            PCS_STORAGEADAPTER_DOCUMENTDB_CONNSTRING = cosmosDBAccountConnectionString;
            PCS_TELEMETRY_DOCUMENTDB_CONNSTRING      = cosmosDBAccountConnectionString; // duplicate
            PCS_TELEMETRYAGENT_DOCUMENTDB_CONNSTRING = cosmosDBAccountConnectionString; // duplicate

            PCS_IOTHUBREACT_ACCESS_CONNSTRING         = iotHubOwnerConnectionString;    // duplicate
            PCS_IOTHUBREACT_HUB_NAME                  = iotHub.Name;
            PCS_IOTHUBREACT_HUB_ENDPOINT              = iotHub.Properties.EventHubEndpoints["events"].Endpoint;
            PCS_IOTHUBREACT_HUB_CONSUMERGROUP         = iotHubOnboardingConsumerGroupName;
            PCS_IOTHUBREACT_HUB_PARTITIONS            = $"{iotHubEventHubEndpointsPartitionsCount}";
            PCS_IOTHUBREACT_AZUREBLOB_ACCOUNT         = storageAccount.Name;
            PCS_IOTHUBREACT_AZUREBLOB_KEY             = storageAccountKey.Value;
            PCS_IOTHUBREACT_AZUREBLOB_ENDPOINT_SUFFIX = azureEnvironment.StorageEndpointSuffix;

            PCS_ASA_DATA_AZUREBLOB_ACCOUNT         = PCS_IOTHUBREACT_AZUREBLOB_ACCOUNT;         // duplicate
            PCS_ASA_DATA_AZUREBLOB_KEY             = PCS_IOTHUBREACT_AZUREBLOB_KEY;             // duplicate
            PCS_ASA_DATA_AZUREBLOB_ENDPOINT_SUFFIX = PCS_IOTHUBREACT_AZUREBLOB_ENDPOINT_SUFFIX; // duplicate

            PCS_EVENTHUB_CONNSTRING            = eventHubConnectionString;
            PCS_EVENTHUB_NAME                  = eventHub.Name;
            PCS_SERVICEBUS_CONNSTRING          = serviceBusConnectionString;
            PCS_KEYVAULT_URL                   = keyVault.Properties.VaultUri;
            PCS_WORKSPACE_NAME                 = operationalInsightsWorkspace.Name;
            PCS_APPINSIGHTS_NAME               = applicationInsightsComponent.Name;
            PCS_APPINSIGHTS_INSTRUMENTATIONKEY = applicationInsightsComponent.InstrumentationKey;
            PCS_SERVICE_URL        = $"https://{webSite.HostNames[0]}";
            PCS_SIGNALR_CONNSTRING = signalRConnectionString;

            PCS_AUTH_HTTPSREDIRECTPORT = "0";
            PCS_AUTH_REQUIRED          = "true";
            PCS_AUTH_AUDIENCE          = serviceApplication.IdentifierUris.First();
            PCS_AUTH_ISSUER            = $"https://sts.windows.net/{tenantId.ToString()}/";

            PCS_WEBUI_AUTH_AAD_APPID     = clientApplication.AppId;
            PCS_WEBUI_AUTH_AAD_AUTHORITY = azureEnvironment.AuthenticationEndpoint;
            PCS_WEBUI_AUTH_AAD_TENANT    = tenantId.ToString();

            PCS_CORS_WHITELIST = "*";

            REACT_APP_PCS_AUTH_REQUIRED            = PCS_AUTH_REQUIRED;            // duplicate
            REACT_APP_PCS_AUTH_AUDIENCE            = PCS_AUTH_AUDIENCE;            // duplicate
            REACT_APP_PCS_AUTH_ISSUER              = PCS_AUTH_ISSUER;              // duplicate
            REACT_APP_PCS_WEBUI_AUTH_AAD_APPID     = PCS_WEBUI_AUTH_AAD_APPID;     // duplicate
            REACT_APP_PCS_WEBUI_AUTH_AAD_AUTHORITY = PCS_WEBUI_AUTH_AAD_AUTHORITY; // duplicate
            REACT_APP_PCS_WEBUI_AUTH_AAD_TENANT    = PCS_WEBUI_AUTH_AAD_TENANT;    // duplicate

            Dict = new Dictionary <string, string> {
                { "_HUB_CS", _HUB_CS },
                { "PCS_IOTHUB_CONNSTRING", PCS_IOTHUB_CONNSTRING },
                { "PCS_STORAGEADAPTER_DOCUMENTDB_CONNSTRING", PCS_STORAGEADAPTER_DOCUMENTDB_CONNSTRING },
                { "PCS_TELEMETRY_DOCUMENTDB_CONNSTRING", PCS_TELEMETRY_DOCUMENTDB_CONNSTRING },
                { "PCS_TELEMETRYAGENT_DOCUMENTDB_CONNSTRING", PCS_TELEMETRYAGENT_DOCUMENTDB_CONNSTRING },
                { "PCS_IOTHUBREACT_ACCESS_CONNSTRING", PCS_IOTHUBREACT_ACCESS_CONNSTRING },
                { "PCS_IOTHUBREACT_HUB_NAME", PCS_IOTHUBREACT_HUB_NAME },
                { "PCS_IOTHUBREACT_HUB_ENDPOINT", PCS_IOTHUBREACT_HUB_ENDPOINT },
                { "PCS_IOTHUBREACT_HUB_CONSUMERGROUP", PCS_IOTHUBREACT_HUB_CONSUMERGROUP },
                { "PCS_IOTHUBREACT_HUB_PARTITIONS", PCS_IOTHUBREACT_HUB_PARTITIONS },
                { "PCS_IOTHUBREACT_AZUREBLOB_ACCOUNT", PCS_IOTHUBREACT_AZUREBLOB_ACCOUNT },
                { "PCS_IOTHUBREACT_AZUREBLOB_KEY", PCS_IOTHUBREACT_AZUREBLOB_KEY },
                { "PCS_IOTHUBREACT_AZUREBLOB_ENDPOINT_SUFFIX", PCS_IOTHUBREACT_AZUREBLOB_ENDPOINT_SUFFIX },
                { "PCS_ASA_DATA_AZUREBLOB_ACCOUNT", PCS_ASA_DATA_AZUREBLOB_ACCOUNT },
                { "PCS_ASA_DATA_AZUREBLOB_KEY", PCS_ASA_DATA_AZUREBLOB_KEY },
                { "PCS_ASA_DATA_AZUREBLOB_ENDPOINT_SUFFIX", PCS_ASA_DATA_AZUREBLOB_ENDPOINT_SUFFIX },
                { "PCS_EVENTHUB_CONNSTRING", PCS_EVENTHUB_CONNSTRING },
                { "PCS_EVENTHUB_NAME", PCS_EVENTHUB_NAME },
                { "PCS_SERVICEBUS_CONNSTRING", PCS_SERVICEBUS_CONNSTRING },
                { "PCS_KEYVAULT_URL", PCS_KEYVAULT_URL },
                { "PCS_WORKSPACE_NAME", PCS_WORKSPACE_NAME },
                { "PCS_APPINSIGHTS_NAME", PCS_APPINSIGHTS_NAME },
                { "PCS_APPINSIGHTS_INSTRUMENTATIONKEY", PCS_APPINSIGHTS_INSTRUMENTATIONKEY },
                { "PCS_SERVICE_URL", PCS_SERVICE_URL },
                { "PCS_SIGNALR_CONNSTRING", PCS_SIGNALR_CONNSTRING },
                { "PCS_AUTH_HTTPSREDIRECTPORT", PCS_AUTH_HTTPSREDIRECTPORT },
                { "PCS_AUTH_REQUIRED", PCS_AUTH_REQUIRED },
                { "PCS_AUTH_AUDIENCE", PCS_AUTH_AUDIENCE },
                { "PCS_AUTH_ISSUER", PCS_AUTH_ISSUER },
                { "PCS_WEBUI_AUTH_AAD_APPID", PCS_WEBUI_AUTH_AAD_APPID },
                { "PCS_WEBUI_AUTH_AAD_AUTHORITY", PCS_WEBUI_AUTH_AAD_AUTHORITY },
                { "PCS_WEBUI_AUTH_AAD_TENANT", PCS_WEBUI_AUTH_AAD_TENANT },
                { "PCS_CORS_WHITELIST", PCS_CORS_WHITELIST },
                { "REACT_APP_PCS_AUTH_REQUIRED", REACT_APP_PCS_AUTH_REQUIRED },
                { "REACT_APP_PCS_AUTH_AUDIENCE", REACT_APP_PCS_AUTH_AUDIENCE },
                { "REACT_APP_PCS_AUTH_ISSUER", REACT_APP_PCS_AUTH_ISSUER },
                { "REACT_APP_PCS_WEBUI_AUTH_AAD_APPID", REACT_APP_PCS_WEBUI_AUTH_AAD_APPID },
                { "REACT_APP_PCS_WEBUI_AUTH_AAD_AUTHORITY", REACT_APP_PCS_WEBUI_AUTH_AAD_AUTHORITY },
                { "REACT_APP_PCS_WEBUI_AUTH_AAD_TENANT", REACT_APP_PCS_WEBUI_AUTH_AAD_TENANT }
            };
        }
コード例 #27
0
 public DeploymentSlotImpl(string name, SiteInner innerObject, SiteConfigResourceInner configObject, WebAppImpl parent, IAppServiceManager manager)
     : base(name, innerObject, configObject, parent, manager)
 {
 }
コード例 #28
0
 public FunctionDeploymentSlotImpl(string name, SiteInner innerObject, SiteConfigResourceInner configObject,
                                   SiteLogsConfigInner logConfig, FunctionAppImpl parent, IAppServiceManager manager)
     : base(name, innerObject, configObject, logConfig, parent, manager)
 {
 }
コード例 #29
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 ??= 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;
            }
        }
コード例 #30
0
        ///GENMHASH:07FBC6D492A2E1E463B39D4D7FFC40E9:66A6C8EDFAA0E618EA9FC53E296A637E

        internal async override Task <SiteInner> CreateOrUpdateInnerAsync(SiteInner site, CancellationToken cancellationToken = default(CancellationToken))
        {
            return(await Manager.Inner.WebApps.CreateOrUpdateAsync(ResourceGroupName, Name, site, cancellationToken : cancellationToken));
        }