private void UpdateAfdCustomDomain() { try { AFDDomainHttpsParameters tlsSettings = null; ResourceReference azureDnsZoneId = null; if (MyInvocation.BoundParameters.ContainsKey("AzureDnsZoneId")) { azureDnsZoneId = new ResourceReference(this.AzureDnsZoneId); } if (ParameterSetName == AfdParameterSet.AfdCustomDomainCustomerCertificate) { tlsSettings = new AFDDomainHttpsParameters { CertificateType = "CustomerCertificate", MinimumTlsVersion = AfdUtilities.CreateMinimumTlsVersion(this.MinimumTlsVersion), Secret = new ResourceReference(this.SecretId) }; } PSAfdCustomDomain psAfdCustomDomain = this.CdnManagementClient.AFDCustomDomains.Update(this.ResourceGroupName, this.ProfileName, this.CustomDomainName, tlsSettings, azureDnsZoneId).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> /// Updates an existing domain within a 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='tlsSettings'> /// The configuration specifying how to enable HTTPS for the domain - using /// AzureFrontDoor managed certificate or user's own certificate. If not /// specified, enabling ssl uses AzureFrontDoor managed certificate by default. /// </param> /// <param name='azureDnsZone'> /// Resource reference to the Azure DNS zone /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <AFDDomain> BeginUpdateAsync(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, AFDDomainHttpsParameters tlsSettings = default(AFDDomainHttpsParameters), ResourceReference azureDnsZone = default(ResourceReference), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, customDomainName, tlsSettings, azureDnsZone, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Updates an existing domain within a 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='tlsSettings'> /// The configuration specifying how to enable HTTPS for the domain - using /// AzureFrontDoor managed certificate or user's own certificate. If not /// specified, enabling ssl uses AzureFrontDoor managed certificate by default. /// </param> /// <param name='azureDnsZone'> /// Resource reference to the Azure DNS zone /// </param> public static AFDDomain BeginUpdate(this IAFDCustomDomainsOperations operations, string resourceGroupName, string profileName, string customDomainName, AFDDomainHttpsParameters tlsSettings = default(AFDDomainHttpsParameters), ResourceReference azureDnsZone = default(ResourceReference)) { return(operations.BeginUpdateAsync(resourceGroupName, profileName, customDomainName, tlsSettings, azureDnsZone).GetAwaiter().GetResult()); }