Skip to content

Commit 557e3a8

Browse files
committed
Enable Az Cdn Custom Domain Https
1 parent 4acf825 commit 557e3a8

6 files changed

+106
-96
lines changed

src/Cdn/Cdn.Autorest/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ directive:
5959
- SecurityPolicyPropertiesParameters
6060
- SecretParameters
6161
- CustomDomainHttpsParameters
62+
6263
# Generate memory object as parameter of the cmelet.
6364
- model-cmdlet:
6465
- SecurityPolicyWebApplicationFirewallAssociation
@@ -67,6 +68,8 @@ directive:
6768
- CustomerCertificateParameters
6869
- ManagedCertificateParameters
6970
- UrlSigningKeyParameters
71+
- UserManagedHttpsParameters
72+
- CdnManagedHttpsParameters
7073
- DeliveryRuleRemoteAddressCondition
7174
- DeliveryRuleRequestMethodCondition
7275
- DeliveryRuleQueryStringCondition
@@ -95,10 +98,6 @@ directive:
9598
- DeliveryRuleCacheExpirationAction
9699
- DeliveryRuleCacheKeyQueryStringAction
97100
- DeliveryRuleRouteConfigurationOverrideAction
98-
# child classes for CustomDomainHttpsParameters
99-
- UserManagedHttpsParameters
100-
- CdnManagedHttpsParameters
101-
- CustomDomainHttpsParameters
102101

103102
# Following is two common directive which are normally required in all the RPs
104103
# 1. Remove the unexpanded parameter set
@@ -120,6 +119,10 @@ directive:
120119
variant: ^CheckViaIdentity$|^CheckViaIdentityExpanded$
121120
subject: ^NameAvailability$|^EndpointNameAvailability$
122121
remove: true
122+
- where:
123+
variant: ^EnableExpanded$|^EnableViaIdentityExpanded$
124+
subject: ^CustomDomainCustomHttps$
125+
remove: true
123126

124127
# Hide Cdn profile
125128
- where:

src/Cdn/Cdn.Autorest/docs/Enable-AzCdnCustomDomainCustomHttps.md

Lines changed: 10 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ Enable https delivery of the custom domain.
1212

1313
## SYNTAX
1414

15-
### EnableExpanded (Default)
15+
### EnableViaIdentity (Default)
1616
```
17-
Enable-AzCdnCustomDomainCustomHttps -CustomDomainName <String> -EndpointName <String> -ProfileName <String>
18-
-ResourceGroupName <String> -CertificateSource <CertificateSource> -ProtocolType <ProtocolType>
19-
[-SubscriptionId <String>] [-MinimumTlsVersion <MinimumTlsVersion>] [-DefaultProfile <PSObject>] [-PassThru]
17+
Enable-AzCdnCustomDomainCustomHttps -InputObject <ICdnIdentity>
18+
-CustomDomainHttpsParameter <ICustomDomainHttpsParameters> [-DefaultProfile <PSObject>] [-PassThru]
2019
[-Confirm] [-WhatIf] [<CommonParameters>]
2120
```
2221

@@ -27,20 +26,6 @@ Enable-AzCdnCustomDomainCustomHttps -CustomDomainName <String> -EndpointName <St
2726
[-SubscriptionId <String>] [-DefaultProfile <PSObject>] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]
2827
```
2928

30-
### EnableViaIdentity
31-
```
32-
Enable-AzCdnCustomDomainCustomHttps -InputObject <ICdnIdentity>
33-
-CustomDomainHttpsParameter <ICustomDomainHttpsParameters> [-DefaultProfile <PSObject>] [-PassThru]
34-
[-Confirm] [-WhatIf] [<CommonParameters>]
35-
```
36-
37-
### EnableViaIdentityExpanded
38-
```
39-
Enable-AzCdnCustomDomainCustomHttps -InputObject <ICdnIdentity> -CertificateSource <CertificateSource>
40-
-ProtocolType <ProtocolType> [-MinimumTlsVersion <MinimumTlsVersion>] [-DefaultProfile <PSObject>]
41-
[-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]
42-
```
43-
4429
## DESCRIPTION
4530
Enable https delivery of the custom domain.
4631

@@ -66,28 +51,13 @@ PS C:\> {{ Add code here }}
6651

6752
## PARAMETERS
6853

69-
### -CertificateSource
70-
Defines the source of the SSL certificate.
71-
72-
```yaml
73-
Type: Microsoft.Azure.PowerShell.Cmdlets.Cdn.Support.CertificateSource
74-
Parameter Sets: EnableExpanded, EnableViaIdentityExpanded
75-
Aliases:
76-
77-
Required: True
78-
Position: Named
79-
Default value: None
80-
Accept pipeline input: False
81-
Accept wildcard characters: False
82-
```
83-
8454
### -CustomDomainHttpsParameter
8555
The JSON object that contains the properties to secure a custom domain.
8656
To construct, see NOTES section for CUSTOMDOMAINHTTPSPARAMETER properties and create a hash table.
8757

8858
```yaml
8959
Type: Microsoft.Azure.PowerShell.Cmdlets.Cdn.Models.Api20210601.ICustomDomainHttpsParameters
90-
Parameter Sets: Enable, EnableViaIdentity
60+
Parameter Sets: (All)
9161
Aliases:
9262

9363
Required: True
@@ -102,7 +72,7 @@ Name of the custom domain within an endpoint.
10272
10373
```yaml
10474
Type: System.String
105-
Parameter Sets: Enable, EnableExpanded
75+
Parameter Sets: Enable
10676
Aliases:
10777

10878
Required: True
@@ -132,7 +102,7 @@ Name of the endpoint under the profile which is unique globally.
132102
133103
```yaml
134104
Type: System.String
135-
Parameter Sets: Enable, EnableExpanded
105+
Parameter Sets: Enable
136106
Aliases:
137107

138108
Required: True
@@ -148,7 +118,7 @@ To construct, see NOTES section for INPUTOBJECT properties and create a hash tab
148118
149119
```yaml
150120
Type: Microsoft.Azure.PowerShell.Cmdlets.Cdn.Models.ICdnIdentity
151-
Parameter Sets: EnableViaIdentity, EnableViaIdentityExpanded
121+
Parameter Sets: EnableViaIdentity
152122
Aliases:
153123

154124
Required: True
@@ -158,21 +128,6 @@ Accept pipeline input: True (ByValue)
158128
Accept wildcard characters: False
159129
```
160130
161-
### -MinimumTlsVersion
162-
TLS protocol version that will be used for Https
163-
164-
```yaml
165-
Type: Microsoft.Azure.PowerShell.Cmdlets.Cdn.Support.MinimumTlsVersion
166-
Parameter Sets: EnableExpanded, EnableViaIdentityExpanded
167-
Aliases:
168-
169-
Required: False
170-
Position: Named
171-
Default value: None
172-
Accept pipeline input: False
173-
Accept wildcard characters: False
174-
```
175-
176131
### -PassThru
177132
Returns true when the command succeeds
178133
@@ -193,22 +148,7 @@ Name of the CDN profile which is unique within the resource group.
193148
194149
```yaml
195150
Type: System.String
196-
Parameter Sets: Enable, EnableExpanded
197-
Aliases:
198-
199-
Required: True
200-
Position: Named
201-
Default value: None
202-
Accept pipeline input: False
203-
Accept wildcard characters: False
204-
```
205-
206-
### -ProtocolType
207-
Defines the TLS extension protocol that is used for secure delivery.
208-
209-
```yaml
210-
Type: Microsoft.Azure.PowerShell.Cmdlets.Cdn.Support.ProtocolType
211-
Parameter Sets: EnableExpanded, EnableViaIdentityExpanded
151+
Parameter Sets: Enable
212152
Aliases:
213153

214154
Required: True
@@ -223,7 +163,7 @@ Name of the Resource group within the Azure subscription.
223163
224164
```yaml
225165
Type: System.String
226-
Parameter Sets: Enable, EnableExpanded
166+
Parameter Sets: Enable
227167
Aliases:
228168

229169
Required: True
@@ -238,7 +178,7 @@ Azure Subscription ID.
238178
239179
```yaml
240180
Type: System.String
241-
Parameter Sets: Enable, EnableExpanded
181+
Parameter Sets: Enable
242182
Aliases:
243183

244184
Required: False

src/Cdn/Cdn.Autorest/test/Enable-AzCdnCustomDomainCustomHttps.Tests.ps1

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,86 @@ if(($null -eq $TestName) -or ($TestName -contains 'Enable-AzCdnCustomDomainCusto
1515
}
1616

1717
Describe 'Enable-AzCdnCustomDomainCustomHttps' {
18-
It 'EnableExpanded' -skip {
19-
{ throw [System.NotImplementedException] } | Should -Not -Throw
20-
}
18+
It 'Enable' {
19+
{
20+
$subId = "27cafca8-b9a4-4264-b399-45d0c9cca1ab"
21+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
22+
try
23+
{
24+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
25+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location -SubscriptionId $subId
2126

22-
It 'Enable' -skip {
23-
{ throw [System.NotImplementedException] } | Should -Not -Throw
24-
}
27+
$cdnProfileName = 'p-' + (RandomString -allChars $false -len 6);
28+
Write-Host -ForegroundColor Green "Use cdnProfileName : $($cdnProfileName)"
29+
30+
$profileSku = "Standard_Microsoft";
31+
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global -SubscriptionId $subId
32+
33+
# Hard-coding host and endpoint names due to requirement for DNS CNAME
34+
$endpointName = 'e-powershell-20220407-oigr9w'
35+
$customDomainHostName = 'e-powershell-20220407-oigr9w.cdne2e.azfdtest.xyz'
36+
$customDomainName = 'cd-' + (RandomString -allChars $false -len 6);
37+
$origin = @{
38+
Name = "origin1"
39+
HostName = "host1.hello.com"
40+
};
41+
$location = "westus"
42+
Write-Host -ForegroundColor Green "Create endpointName : $($endpointName), origin.Name : $($origin.Name), origin.HostName : $($origin.HostName)"
2543

26-
It 'EnableViaIdentityExpanded' -skip {
27-
{ throw [System.NotImplementedException] } | Should -Not -Throw
44+
New-AzCdnEndpoint -Name $endpointName -ResourceGroupName $ResourceGroupName -ProfileName $cdnProfileName -Location $location -Origin $origin -SubscriptionId $subId
45+
New-AzCdnCustomDomain -EndpointName $endpointName -Name $customDomainName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName -HostName $customDomainHostName -SubscriptionId $subId
46+
$httpsParameter = New-AzCdnUserManagedHttpsParametersObject -CertificateSource "AzureKeyVault" `
47+
-CertificateSourceParameterResourceGroupName $ResourceGroupName -CertificateSourceParameterSecretName "wildcard-cdne2e-azfdtest-xyz" `
48+
-CertificateSourceParameterSubscriptionId $subId -CertificateSourceParameterVaultName "huaiyizkvtest" `
49+
-ProtocolType "ServerNameIndication"
50+
$customDomain = Enable-AzCdnCustomDomainCustomHttps -CustomDomainName $customDomainName -EndpointName $endpointName `
51+
-ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName -CustomDomainHttpsParameter $httpsParameter -SubscriptionId $subId
52+
53+
$customDomain.CustomHttpsProvisioningState | Should -Not -Be "Disabled"
54+
} Finally
55+
{
56+
Remove-AzResourceGroup -Name $ResourceGroupName -SubscriptionId $subId -NoWait
57+
}
58+
} | Should -Not -Throw
2859
}
2960

30-
It 'EnableViaIdentity' -skip {
31-
{ throw [System.NotImplementedException] } | Should -Not -Throw
61+
It 'EnableViaIdentity' {
62+
{
63+
$PSDefaultParameterValues['Disabled'] = $true
64+
$subId = "27cafca8-b9a4-4264-b399-45d0c9cca1ab"
65+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
66+
try
67+
{
68+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
69+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location -SubscriptionId $subId
70+
71+
$cdnProfileName = 'p-' + (RandomString -allChars $false -len 6);
72+
Write-Host -ForegroundColor Green "Use cdnProfileName : $($cdnProfileName)"
73+
74+
$profileSku = "Standard_Microsoft";
75+
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global -SubscriptionId $subId
76+
77+
# Hard-coding host and endpoint names due to requirement for DNS CNAME
78+
$endpointName = 'e-powershell-20220407-2clpwi'
79+
$customDomainHostName = 'e-powershell-20220407-2clpwi.cdne2e.azfdtest.xyz'
80+
$customDomainName = 'cd-' + (RandomString -allChars $false -len 6);
81+
$origin = @{
82+
Name = "origin1"
83+
HostName = "host1.hello.com"
84+
};
85+
$location = "westus"
86+
Write-Host -ForegroundColor Green "Create endpointName : $($endpointName), origin.Name : $($origin.Name), origin.HostName : $($origin.HostName)"
87+
88+
New-AzCdnEndpoint -Name $endpointName -ResourceGroupName $ResourceGroupName -ProfileName $cdnProfileName -Location $location -Origin $origin -SubscriptionId $subId
89+
$customDomain = New-AzCdnCustomDomain -EndpointName $endpointName -Name $customDomainName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName -HostName $customDomainHostName -SubscriptionId $subId
90+
$httpsParameter = New-AzCdnManagedHttpsParametersObject -CertificateSource "Cdn" -CertificateSourceParameterCertificateType "Dedicated" -ProtocolType "ServerNameIndication"
91+
$customDomain = $customDomain | Enable-AzCdnCustomDomainCustomHttps -CustomDomainHttpsParameter $httpsParameter
92+
93+
$customDomain.CustomHttpsProvisioningState | Should -Not -Be "Disabled"
94+
} Finally
95+
{
96+
Remove-AzResourceGroup -Name $ResourceGroupName -SubscriptionId $subId -NoWait
97+
}
98+
} | Should -Not -Throw
3299
}
33100
}

src/Cdn/Cdn.Autorest/test/Get-AzCdnCustomDomain.Tests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Describe 'Get-AzCdnCustomDomain' {
3131
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global -SubscriptionId $subId
3232

3333
# Hard-coding host and endpoint names due to requirement for DNS CNAME
34-
$endpointName = 'e-cyzd8j'
35-
$customDomainHostName = 'e-cyzd8j.ps.cdne2e.azfdtest.xyz'
34+
$endpointName = 'e-20220407-cyzd8j'
35+
$customDomainHostName = 'e-20220407-cyzd8j.ps.cdne2e.azfdtest.xyz'
3636
$customDomainName = 'cd-' + (RandomString -allChars $false -len 6);
3737
$origin = @{
3838
Name = "origin1"
@@ -69,8 +69,8 @@ Describe 'Get-AzCdnCustomDomain' {
6969
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global -SubscriptionId $subId
7070

7171
# Hard-coding host and endpoint names due to requirement for DNS CNAME
72-
$endpointName = 'e-k0eyx9'
73-
$customDomainHostName = 'e-k0eyx9.ps.cdne2e.azfdtest.xyz'
72+
$endpointName = 'e-20220407-k0eyx9'
73+
$customDomainHostName = 'e-20220407-k0eyx9.ps.cdne2e.azfdtest.xyz'
7474
$customDomainName = 'cd-' + (RandomString -allChars $false -len 6);
7575
$origin = @{
7676
Name = "origin1"
@@ -109,8 +109,8 @@ Describe 'Get-AzCdnCustomDomain' {
109109
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global -SubscriptionId $subId
110110

111111
# Hard-coding host and endpoint names due to requirement for DNS CNAME
112-
$endpointName = 'e-315rgw'
113-
$customDomainHostName = 'e-315rgw.ps.cdne2e.azfdtest.xyz'
112+
$endpointName = 'e-20220407-315rgw'
113+
$customDomainHostName = 'e-20220407-315rgw.ps.cdne2e.azfdtest.xyz'
114114
$customDomainName = 'cd-' + (RandomString -allChars $false -len 6);
115115
$origin = @{
116116
Name = "origin1"

src/Cdn/Cdn.Autorest/test/New-AzCdnCustomDomain.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Describe 'New-AzCdnCustomDomain' {
3131
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global -SubscriptionId $subId
3232

3333
# Hard-coding host and endpoint names due to requirement for DNS CNAME
34-
$endpointName = 'e-52wg49'
35-
$customDomainHostName = 'e-52wg49.ps.cdne2e.azfdtest.xyz'
34+
$endpointName = 'e-20220407-52wg49'
35+
$customDomainHostName = 'e-20220407-52wg49.ps.cdne2e.azfdtest.xyz'
3636
$customDomainName = 'cd-' + (RandomString -allChars $false -len 6);
3737
$origin = @{
3838
Name = "origin1"

src/Cdn/Cdn.Autorest/test/Remove-AzCdnCustomDomain.Tests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Describe 'Remove-AzCdnCustomDomain' {
3131
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global -SubscriptionId $subId
3232

3333
# Hard-coding host and endpoint names due to requirement for DNS CNAME
34-
$endpointName = 'e-8fwkya'
35-
$customDomainHostName = 'e-8fwkya.ps.cdne2e.azfdtest.xyz'
34+
$endpointName = 'e-20220407-8fwkya'
35+
$customDomainHostName = 'e-20220407-8fwkya.ps.cdne2e.azfdtest.xyz'
3636
$customDomainName = 'cd-' + (RandomString -allChars $false -len 6);
3737
$origin = @{
3838
Name = "origin1"
@@ -68,8 +68,8 @@ Describe 'Remove-AzCdnCustomDomain' {
6868
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global -SubscriptionId $subId
6969

7070
# Hard-coding host and endpoint names due to requirement for DNS CNAME
71-
$endpointName = 'e-lw8iyz'
72-
$customDomainHostName = 'e-lw8iyz.ps.cdne2e.azfdtest.xyz'
71+
$endpointName = 'e-20220407-lw8iyz'
72+
$customDomainHostName = 'e-20220407-lw8iyz.ps.cdne2e.azfdtest.xyz'
7373
$customDomainName = 'cd-' + (RandomString -allChars $false -len 6);
7474
$origin = @{
7575
Name = "origin1"

0 commit comments

Comments
 (0)