コード例 #1
0
        public async Task TestDomainCheckDomainInValid()
        {
            _moqBusinessServiceDomain.Setup(a => a.Create(It.IsAny <int>(), It.IsAny <string>())).Returns(Task.FromResult(_domain));
            _moqBusinessServiceDomain.Setup(a => a.ValidDomain(It.IsAny <string>())).Returns(false);

            _iAppServiceDomain = new AppServiceDomain(_moqBusinessServiceDomain.Object, _moqBusinessServiceDomainIpAddress.Object, _moqBusinessServiceOpenPort.Object);

            var result = await _iAppServiceDomain.DomainCheck(0, string.Empty);

            var objectResponse = result as ObjectResult;

            Assert.Equal(404, objectResponse.StatusCode);
        }
コード例 #2
0
 private static IWebApp CreateWebApp(IAzure azure, IAppServiceDomain domain, string rgName, string name, IAppServicePlan plan)
 {
     return(azure.WebApps.Define(name)
            .WithExistingWindowsPlan(plan)
            .WithExistingResourceGroup(rgName)
            .WithManagedHostnameBindings(domain, name)
            .DefineSslBinding()
            .ForHostname(name + "." + domain.Name)
            .WithPfxCertificateToUpload(Path.Combine(Utilities.ProjectPath, "Asset", pfxPath), CERT_PASSWORD)
            .WithSniBasedSsl()
            .Attach()
            .DefineSourceControl()
            .WithPublicGitRepository("https://github.Com/jianghaolu/azure-site-test")
            .WithBranch("master")
            .Attach()
            .Create());
 }
コード例 #3
0
 /// <summary>
 /// Binds to a domain purchased from Azure.
 /// </summary>
 /// <param name="domain">The domain purchased from Azure.</param>
 /// <return>The next stage of the definition.</return>
 HostNameBinding.UpdateDefinition.IWithSubDomain <WebAppBase.Update.IUpdate <FluentT> > HostNameBinding.UpdateDefinition.IWithDomain <WebAppBase.Update.IUpdate <FluentT> > .WithAzureManagedDomain(IAppServiceDomain domain)
 {
     return(this.WithAzureManagedDomain(domain));
 }
コード例 #4
0
        ///GENMHASH:8F156E891E25FA23FCB8AE0E23601BEC:7FF0A8A46536F20F09EC2FE338F3B99E
        public HostNameBindingImpl <FluentT, FluentImplT, DefAfterRegionT, DefAfterGroupT, UpdateT> WithAzureManagedDomain(IAppServiceDomain domain)
        {
            Inner.DomainId     = domain.Id;
            Inner.HostNameType = Models.HostNameType.Managed;
            domainName         = domain.Name;

            return(this);
        }
コード例 #5
0
        /**
         * Azure App Service sample for managing function apps.
         *  - app service plan, function app
         *    - Create 2 function apps under the same new app service plan
         *  - domain
         *    - Create a domain
         *  - certificate
         *    - Upload a self-signed wildcard certificate
         *    - update both function apps to use the domain and the created wildcard SSL certificate
         */
        public static void RunSample(IAzure azure)
        {
            string app1Name     = SdkContext.RandomResourceName("webapp1-", 20);
            string app2Name     = SdkContext.RandomResourceName("webapp2-", 20);
            string rgName       = SdkContext.RandomResourceName("rgNEMV_", 24);
            string domainName   = SdkContext.RandomResourceName("jsdkdemo-", 20) + ".com";
            string certPassword = "******";

            try {
                //============================================================
                // Create a function app with a new app service plan

                Utilities.Log("Creating function app " + app1Name + "...");

                IFunctionApp app1 = azure.AppServices.FunctionApps.Define(app1Name)
                                    .WithRegion(Region.USWest)
                                    .WithNewResourceGroup(rgName)
                                    .Create();

                Utilities.Log("Created function app " + app1.Name);
                Utilities.Print(app1);

                //============================================================
                // Create a second function app with the same app service plan

                Utilities.Log("Creating another function app " + app2Name + "...");
                IFunctionApp app2 = azure.AppServices.FunctionApps.Define(app2Name)
                                    .WithRegion(Region.USWest)
                                    .WithExistingResourceGroup(rgName)
                                    .Create();

                Utilities.Log("Created function app " + app2.Name);
                Utilities.Print(app2);

                //============================================================
                // Purchase a domain (will be canceled for a full refund)

                Utilities.Log("Purchasing a domain " + domainName + "...");

                IAppServiceDomain domain = azure.AppServices.AppServiceDomains.Define(domainName)
                                           .WithExistingResourceGroup(rgName)
                                           .DefineRegistrantContact()
                                           .WithFirstName("Jon")
                                           .WithLastName("Doe")
                                           .WithEmail("*****@*****.**")
                                           .WithAddressLine1("123 4th Ave")
                                           .WithCity("Redmond")
                                           .WithStateOrProvince("WA")
                                           .WithCountry(CountryISOCode.UnitedStates)
                                           .WithPostalCode("98052")
                                           .WithPhoneCountryCode(CountryPhoneCode.UnitedStates)
                                           .WithPhoneNumber("4258828080")
                                           .Attach()
                                           .WithDomainPrivacyEnabled(true)
                                           .WithAutoRenewEnabled(false)
                                           .Create();
                Utilities.Log("Purchased domain " + domain.Name);
                Utilities.Print(domain);

                //============================================================
                // Bind domain to function app 1

                Utilities.Log("Binding http://" + app1Name + "." + domainName + " to function app " + app1Name + "...");

                app1 = app1.Update()
                       .DefineHostnameBinding()
                       .WithAzureManagedDomain(domain)
                       .WithSubDomain(app1Name)
                       .WithDnsRecordType(CustomHostNameDnsRecordType.CName)
                       .Attach()
                       .Apply();

                Utilities.Log("Finished binding http://" + app1Name + "." + domainName + " to function app " + app1Name);
                Utilities.Print(app1);

                //============================================================
                // Create a self-singed SSL certificate
                var pfxPath = "webapp_" + nameof(ManageFunctionAppWithDomainSsl).ToLower() + ".pfx";

                Utilities.Log("Creating a self-signed certificate " + pfxPath + "...");

                Utilities.CreateCertificate(domainName, pfxPath, CertificatePassword);

                Utilities.Log("Created self-signed certificate " + pfxPath);

                //============================================================
                // Bind domain to function app 2 and turn on wild card SSL for both

                Utilities.Log("Binding https://" + app1Name + "." + domainName + " to function app " + app1Name + "...");

                app1 = app1.Update()
                       .WithManagedHostnameBindings(domain, app1Name)
                       .DefineSslBinding()
                       .ForHostname(app1Name + "." + domainName)
                       .WithPfxCertificateToUpload(Path.Combine(Utilities.ProjectPath, "Asset", pfxPath), certPassword)
                       .WithSniBasedSsl()
                       .Attach()
                       .Apply();

                Utilities.Log("Finished binding http://" + app1Name + "." + domainName + " to function app " + app1Name);
                Utilities.Print(app1);

                Utilities.Log("Binding https://" + app2Name + "." + domainName + " to function app " + app2Name + "...");

                app2 = app2.Update()
                       .WithManagedHostnameBindings(domain, app2Name)
                       .DefineSslBinding()
                       .ForHostname(app2Name + "." + domainName)
                       .WithPfxCertificateToUpload(Path.Combine(Utilities.ProjectPath, "Asset", pfxPath), certPassword)
                       .WithSniBasedSsl()
                       .Attach()
                       .Apply();

                Utilities.Log("Finished binding http://" + app2Name + "." + domainName + " to function app " + app2Name);
                Utilities.Print(app2);
            }
            finally
            {
                try
                {
                    Utilities.Log("Deleting Resource Group: " + rgName);
                    azure.ResourceGroups.DeleteByName(rgName);
                    Utilities.Log("Deleted Resource Group: " + rgName);
                }
                catch (NullReferenceException)
                {
                    Utilities.Log("Did not create any resources in Azure. No clean up is necessary");
                }
                catch (Exception g)
                {
                    Utilities.Log(g);
                }
            }
        }
コード例 #6
0
 /// <summary>
 /// Verifies the ownership of the domain by providing the Azure purchased domain.
 /// </summary>
 /// <param name="domain">The Azure managed domain.</param>
 void Microsoft.Azure.Management.AppService.Fluent.IAppServiceCertificateOrder.VerifyDomainOwnership(IAppServiceDomain domain)
 {
     this.VerifyDomainOwnership(domain);
 }
コード例 #7
0
 /// <summary>
 /// Specifies the Azure managed domain to verify the ownership of the domain.
 /// </summary>
 /// <param name="domain">The Azure managed domain.</param>
 /// <return>The next stage of the definition.</return>
 AppServiceCertificateOrder.Definition.IWithKeyVault AppServiceCertificateOrder.Definition.IWithDomainVerification.WithDomainVerification(IAppServiceDomain domain)
 {
     return(this.WithDomainVerification(domain) as AppServiceCertificateOrder.Definition.IWithKeyVault);
 }
コード例 #8
0
 /// <summary>
 /// Verifies the ownership of the domain by providing the Azure purchased domain.
 /// </summary>
 /// <param name="domain">The Azure managed domain.</param>
 /// <return>An Observable to the result.</return>
 async Task Microsoft.Azure.Management.AppService.Fluent.IAppServiceCertificateOrder.VerifyDomainOwnershipAsync(IAppServiceDomain domain, CancellationToken cancellationToken)
 {
     await this.VerifyDomainOwnershipAsync(domain, cancellationToken);
 }
コード例 #9
0
 public DomainsController(IAppServiceDomain iAppServiceDomain)
 {
     _iAppServiceDomain = iAppServiceDomain;
 }
コード例 #10
0
 ///GENMHASH:614D2D9852F00FD5BFCAF60BA2A659B0:86E327FE34A305973AC1A32ECEC60D57
 public AppServiceCertificateOrderImpl WithDomainVerification(IAppServiceDomain domain)
 {
     this.domainVerifyDomain = domain;
     return(this);
 }
コード例 #11
0
 ///GENMHASH:247F3F9D51B0218A2892B535E30EFFE4:15E338262AA4F8C7461DD6FBB41E746B
 public void VerifyDomainOwnership(IAppServiceDomain domain)
 {
     VerifyDomainOwnership(domain);
 }
コード例 #12
0
 ///GENMHASH:6B60EDADBCA134B9C9928244109B6E1B:5781A8E04FCEFEA9CF50B97FD61BE42B
 public async Task VerifyDomainOwnershipAsync(IAppServiceDomain domain, CancellationToken cancellationToken = default(CancellationToken))
 {
     await domain.VerifyDomainOwnershipAsync(Name, DomainVerificationToken(), cancellationToken);
 }