private void CreateAfdCustomDomain() { try { AFDDomain afdCustomDomain = new AFDDomain { HostName = this.HostName, }; if (MyInvocation.BoundParameters.ContainsKey("AzureDnsZoneId")) { afdCustomDomain.AzureDnsZone = new ResourceReference(this.AzureDnsZoneId); } if (ParameterSetName == AfdParameterSet.AfdCustomDomainCustomerCertificate) { afdCustomDomain.TlsSettings = new AFDDomainHttpsParameters { CertificateType = "CustomerCertificate", MinimumTlsVersion = AfdUtilities.CreateMinimumTlsVersion(this.MinimumTlsVersion), Secret = new ResourceReference(this.SecretId) }; } PSAfdCustomDomain psAfdCustomDomain = this.CdnManagementClient.AFDCustomDomains.Create(this.ResourceGroupName, this.ProfileName, this.CustomDomainName, afdCustomDomain).ToPSAfdCustomDomain(); WriteObject(psAfdCustomDomain); } catch (AfdErrorResponseException errorResponse) { throw new PSArgumentException(errorResponse.Response.Content); } }
private void CreateAfdCustomDomain() { try { AFDDomain afdCustomDomain = new AFDDomain { HostName = this.HostName }; PSAfdCustomDomain psAfdCustomDomain = this.CdnManagementClient.AFDCustomDomains.Create(this.ResourceGroupName, this.ProfileName, this.CustomDomainName, afdCustomDomain).ToPSAfdCustomDomain(); WriteObject(psAfdCustomDomain); } catch (AfdErrorResponseException errorResponse) { throw new PSArgumentException(errorResponse.Response.Content); } }
public void AFDCustomDomainUpdateTest() { var handler1 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; var handler2 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (MockContext context = MockContext.Start(this.GetType())) { // Create clients var cdnMgmtClient = CdnTestUtilities.GetCdnManagementClient(context, handler1); var resourcesClient = CdnTestUtilities.GetResourceManagementClient(context, handler2); // Create resource group var resourceGroupName = CdnTestUtilities.CreateResourceGroup(resourcesClient); try { // Create a standard Azure frontdoor profile string profileName = TestUtilities.GenerateName("profile"); Profile createParameters = new Profile { Location = "WestUs", Sku = new Sku { Name = SkuName.StandardAzureFrontDoor }, Tags = new Dictionary <string, string> { { "key1", "value1" }, { "key2", "value2" } } }; var profile = cdnMgmtClient.Profiles.Create(resourceGroupName, profileName, createParameters); // Create a standard Azure frontdoor profile secret string secretName = TestUtilities.GenerateName("secretName"); var secretSource = new ResourceReference("/subscriptions/d7cfdb98-c118-458d-8bdf-246be66b1f5e/resourceGroups/cdn-powershell-test/providers/Microsoft.KeyVault/vaults/cdn-powershell-test-kv/certificates/cdn-powershell-test-cer"); CustomerCertificateParameters parameters = new CustomerCertificateParameters(secretSource) { UseLatestVersion = true, SubjectAlternativeNames = new List <string>(), }; var secret = cdnMgmtClient.Secrets.Create(resourceGroupName, profileName, secretName, parameters); // Create a standard Azure frontdoor profile customDomain string customDomainName = TestUtilities.GenerateName("customDomainName"); var hostName = "csharpsdk.dev.cdn.azure.cn"; AFDDomain afdDomainCreateParameters = new AFDDomain() { HostName = hostName, TlsSettings = new AFDDomainHttpsParameters { CertificateType = "CustomerCertificate", MinimumTlsVersion = AfdMinimumTlsVersion.TLS12, Secret = new ResourceReference(secret.Id) }, }; //Need manualy add dns txt record var afdDomain = cdnMgmtClient.AFDCustomDomains.Create(resourceGroupName, profileName, customDomainName, afdDomainCreateParameters); Assert.NotNull(afdDomain); Assert.Equal("Approved", afdDomain.DomainValidationState); var updateTlsSettingsParams = new AFDDomainHttpsParameters { CertificateType = "CustomerCertificate", MinimumTlsVersion = AfdMinimumTlsVersion.TLS10, Secret = new ResourceReference(secret.Id) }; var updatedAfdDomain = cdnMgmtClient.AFDCustomDomains.Update(resourceGroupName, profileName, customDomainName, updateTlsSettingsParams); Assert.NotNull(updateTlsSettingsParams); Assert.Equal("Approved", updatedAfdDomain.DomainValidationState); Assert.Equal(updateTlsSettingsParams.MinimumTlsVersion, updatedAfdDomain.TlsSettings.MinimumTlsVersion); } finally { // Delete resource group _ = CdnTestUtilities.DeleteResourceGroupAsync(resourcesClient, resourceGroupName); } } }
/// <summary> /// Creates a new domain within the specified profile. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of the Resource group within the Azure subscription. /// </param> /// <param name='profileName'> /// Name of the CDN profile which is unique within the resource group. /// </param> /// <param name='customDomainName'> /// Name of the domain under the profile which is unique globally /// </param> /// <param name='customDomain'> /// Domain properties /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <AFDDomain> BeginCreateAsync(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, AFDDomain customDomain, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, customDomain, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates a new domain within the specified profile. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of the Resource group within the Azure subscription. /// </param> /// <param name='profileName'> /// Name of the CDN profile which is unique within the resource group. /// </param> /// <param name='customDomainName'> /// Name of the domain under the profile which is unique globally /// </param> /// <param name='customDomain'> /// Domain properties /// </param> public static AFDDomain BeginCreate(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, AFDDomain customDomain) { return(operations.BeginCreateAsync(resourceGroupName, profileName, customDomainName, customDomain).GetAwaiter().GetResult()); }