Skip to content

Commit df0921b

Browse files
azure-pipelines[bot]azure-powershell-botdolauli
authored
Migrate Cdn from generation to main (#25757)
* Move Cdn to main * Update ChangeLog.md for Cdn --------- Co-authored-by: azure-powershell-bot <[email protected]> Co-authored-by: Xiaogang <[email protected]>
1 parent d51c868 commit df0921b

File tree

160 files changed

+2629
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+2629
-263
lines changed

src/Cdn/Cdn.Autorest/custom/Start-AzFrontDoorCdnProfilePrepareMigration.ps1

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,16 @@ function Start-AzFrontDoorCdnProfilePrepareMigration {
238238
throw "MigrationWebApplicationFirewallMapping parameter instance should be equal to the number of WAF policy instance in the profile."
239239
}
240240

241-
if (($PSBoundParameters.ContainsKey('IdentityType')) -ne ($allPoliciesWithVault.count -gt 0)) {
242-
throw "MSIIdentity should be associated if the front door has Customer Certificates. If not, remove MSIIdentity parameter."
241+
# We should raise a complaint if the customer did not enable managed identity when they have BYOC enabled.
242+
# However, if the customer does not have BYOC but has specified a managed identity, we could ignore the validation for BYOC, no need to keep consisence with Portal behavior.
243+
if (($allPoliciesWithVault.count -gt 0) -and !($PSBoundParameters.ContainsKey('IdentityType')))
244+
{
245+
throw "IdentityType parameter should be provided when the front door has Customer Certificates."
243246
}
244-
Write-Host("The parameters have been successfully validated.")
245247

246-
# Deal with Waf policy
248+
Write-Host("The parameters have been validated successfully.")
249+
250+
# Step1: Deal with Waf policy
247251
if ($PSBoundParameters.ContainsKey('MigrationWebApplicationFirewallMapping')) {
248252
Write-Host("Starting to configure WAF policy upgrades.")
249253

@@ -287,7 +291,7 @@ function Start-AzFrontDoorCdnProfilePrepareMigration {
287291
Write-Host("WAF policy upgrades have been configured successfully.")
288292
}
289293

290-
# Create AFDx Profile
294+
# Step2: Create AFDx Profile
291295
# If create AfdX profile firstly, then an error ("Invalid migrated to waf reference.") will be thrown if the migrated-To-WAF is supposed to created. (not exists in current subscription)
292296
Write-Host("Your new Front Door profile is being created. Please wait until the process has finished completely. This may take several minutes.")
293297
$null = $PSBoundParameters.Remove('IdentityType')
@@ -302,9 +306,8 @@ function Start-AzFrontDoorCdnProfilePrepareMigration {
302306

303307
Write-Host("Your new Front Door profile with the configuration has been successfully created.")
304308

305-
# Deal with MSI parameter
306-
# if ($PSBoundParameters.ContainsKey('IdentityType')) {
307-
if ($allPoliciesWithVault.count -gt 0) {
309+
# Step 3: Deal with MSI parameter
310+
if (${IdentityType}) {
308311
Write-Host("Starting to enable managed identity.")
309312

310313
# Waiting for results of profile created return
@@ -318,7 +321,7 @@ function Start-AzFrontDoorCdnProfilePrepareMigration {
318321

319322
$enableMSISuccessMessage = 'Enabling managed identity succeeded.'
320323
$enableMSIRetryMessage = 'Retrying to enable managed identity...'
321-
$enableMSIErrorMessage = "Enableing managed identity failed."
324+
$enableMSIErrorMessage = "Enabling managed identity failed."
322325
$profileIdentity = RetryCommand -Command 'Update-AzFrontDoorCdnProfile' -CommandArgs $commandArgs -RetryTimes 6 -SecondsDelay 20 -SuccessMessage $enableMSISuccessMessage -RetryMessage $enableMSIRetryMessage -ErrorMessage $enableMSIErrorMessage
323326
$identity = [System.Collections.ArrayList]@()
324327
foreach ($id in $profileIdentity.IdentityUserAssignedIdentity.Values.PrincipalId) {
@@ -331,24 +334,31 @@ function Start-AzFrontDoorCdnProfilePrepareMigration {
331334
$identity.Add($profileIdentity.IdentityPrincipalId) | Out-Null
332335
}
333336

334-
# Waiting for MSI granted access...
337+
# Waiting for Enabling managed identity...
335338
Start-Sleep(20)
336-
Write-Host("Starting to grant managed identity to key vault.")
337-
foreach ($vault in $allPoliciesWithVault) {
338-
foreach ($principal in $identity) {
339-
$grantAccessSuccessMessage = 'Granting managed identity to key vault succeeded.'
340-
$grantAccessRetryMessage = 'Retrying to grant managed identity to key vault...'
341-
$grantAccessErrorMessage = 'Granting managed identity to key vault failed.'
342-
343-
$commandInfo = @{ VaultName = $vault; ObjectId = $principal; PermissionsToSecrets = 'Get'; PermissionsToCertificates = 'Get'; ErrorAction = 'Stop'; BypassObjectIdValidation = $true}
344-
345-
# Set-AzKeyVaultAccessPolicy -VaultName $vault -ObjectId $principal -PermissionsToSecrets Get -PermissionsToCertificates Get
346-
# Adding the parameter `-BypassObjectIdValidation` to bypass the validation when using pipeline to do migration, the type of `-BypassObjectIdValidation` is 'SwitchParameter'.
347-
RetryCommand -Command 'Set-AzKeyVaultAccessPolicy' -CommandArgs $commandInfo -RetryTimes 6 -SecondsDelay 20 -SuccessMessage $grantAccessSuccessMessage -RetryMessage $grantAccessRetryMessage -ErrorMessage $grantAccessErrorMessage
339+
340+
# When the classic front door has BYOC, need to grant managed identity to the key vault.
341+
if ($allPoliciesWithVault.count -gt 0)
342+
{
343+
Write-Host("Starting to grant managed identity to key vault.")
344+
foreach ($vault in $allPoliciesWithVault) {
345+
foreach ($principal in $identity) {
346+
$grantAccessSuccessMessage = 'Granting managed identity to key vault succeeded.'
347+
$grantAccessRetryMessage = 'Retrying to grant managed identity to key vault...'
348+
$grantAccessErrorMessage = 'Granting managed identity to key vault failed.'
349+
350+
$commandInfo = @{ VaultName = $vault; ObjectId = $principal; PermissionsToSecrets = 'Get'; PermissionsToCertificates = 'Get'; ErrorAction = 'Stop'; BypassObjectIdValidation = $true}
351+
352+
# Set-AzKeyVaultAccessPolicy -VaultName $vault -ObjectId $principal -PermissionsToSecrets Get -PermissionsToCertificates Get
353+
# Adding the parameter `-BypassObjectIdValidation` to bypass the validation when using pipeline to do migration, the type of `-BypassObjectIdValidation` is 'SwitchParameter'.
354+
RetryCommand -Command 'Set-AzKeyVaultAccessPolicy' -CommandArgs $commandInfo -RetryTimes 6 -SecondsDelay 20 -SuccessMessage $grantAccessSuccessMessage -RetryMessage $grantAccessRetryMessage -ErrorMessage $grantAccessErrorMessage
355+
}
348356
}
349-
}
350357

351-
Write-Host("Your have successfully granted managed identity to key vault.")
358+
Write-Host("Your have successfully granted managed identity to key vault.")
359+
}
360+
} else {
361+
Write-Debug("IdentityType paramter not provided and no BYOC for the current front door, skip Managed Identity step.")
352362
}
353363

354364
Write-Host("The change need to be committed after this.")

src/Cdn/Cdn/Az.Cdn.psd1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft Corporation
55
#
6-
# Generated on: 7/31/2024
6+
# Generated on: 8/6/2024
77
#
88

99
@{
@@ -57,10 +57,10 @@ RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '3.0.3'; })
5757
RequiredAssemblies = 'Cdn.Autorest/bin/Az.Cdn.private.dll'
5858

5959
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
60-
# ScriptsToProcess = @()
60+
ScriptsToProcess = @()
6161

6262
# Type files (.ps1xml) to be loaded when importing this module
63-
# TypesToProcess = @()
63+
TypesToProcess = @()
6464

6565
# Format files (.ps1xml) to be loaded when importing this module
6666
FormatsToProcess = 'Cdn.Autorest/Az.Cdn.format.ps1xml'
@@ -216,7 +216,7 @@ PrivateData = @{
216216
PSData = @{
217217

218218
# Tags applied to this module. These help with module discovery in online galleries.
219-
Tags = 'Azure','ResourceManager','ARM','PSModule','Cdn'
219+
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'Cdn'
220220

221221
# A URL to the license for this module.
222222
LicenseUri = 'https://aka.ms/azps-license'
@@ -241,7 +241,7 @@ PrivateData = @{
241241

242242
} # End of PSData hashtable
243243

244-
} # End of PrivateData hashtable
244+
} # End of PrivateData hashtable
245245

246246
# HelpInfo URI of this module
247247
# HelpInfoURI = ''

src/Cdn/Cdn/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
-->
2020

2121
## Upcoming Release
22+
* Added support to enable ManagedIdentity when no BYOC in the classic front door during migration
2223

2324
## Version 3.2.1
2425
* Bypassed object id validation for KeyVault access policy during `Start-AzFrontDoorCdnProfilePrepareMigration`

src/Cdn/Cdn/help/Clear-AzCdnEndpointContent.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,26 @@ Removes a content from CDN.
1616
```
1717
Clear-AzCdnEndpointContent -EndpointName <String> -ProfileName <String> -ResourceGroupName <String>
1818
[-SubscriptionId <String>] -ContentPath <String[]> [-DefaultProfile <PSObject>] [-AsJob] [-NoWait] [-PassThru]
19-
[-WhatIf] [-Confirm] [<CommonParameters>]
19+
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2020
```
2121

2222
### Purge1
2323
```
2424
Clear-AzCdnEndpointContent -EndpointName <String> -ProfileName <String> -ResourceGroupName <String>
2525
[-SubscriptionId <String>] -ContentFilePath <IPurgeParameters> [-DefaultProfile <PSObject>] [-AsJob] [-NoWait]
26-
[-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
26+
[-PassThru] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2727
```
2828

2929
### PurgeViaIdentityExpanded1
3030
```
3131
Clear-AzCdnEndpointContent -InputObject <ICdnIdentity> -ContentPath <String[]> [-DefaultProfile <PSObject>]
32-
[-AsJob] [-NoWait] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
32+
[-AsJob] [-NoWait] [-PassThru] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
3333
```
3434

3535
### PurgeViaIdentity1
3636
```
3737
Clear-AzCdnEndpointContent -InputObject <ICdnIdentity> -ContentFilePath <IPurgeParameters>
38-
[-DefaultProfile <PSObject>] [-AsJob] [-NoWait] [-PassThru] [-WhatIf]
38+
[-DefaultProfile <PSObject>] [-AsJob] [-NoWait] [-PassThru] [-ProgressAction <ActionPreference>] [-WhatIf]
3939
[-Confirm] [<CommonParameters>]
4040
```
4141

@@ -201,6 +201,21 @@ Accept pipeline input: False
201201
Accept wildcard characters: False
202202
```
203203
204+
### -ProgressAction
205+
{{ Fill ProgressAction Description }}
206+
207+
```yaml
208+
Type: System.Management.Automation.ActionPreference
209+
Parameter Sets: (All)
210+
Aliases: proga
211+
212+
Required: False
213+
Position: Named
214+
Default value: None
215+
Accept pipeline input: False
216+
Accept wildcard characters: False
217+
```
218+
204219
### -ResourceGroupName
205220
Name of the Resource group within the Azure subscription.
206221

src/Cdn/Cdn/help/Clear-AzFrontDoorCdnEndpointContent.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@ Removes a content from AzureFrontDoor.
1616
```
1717
Clear-AzFrontDoorCdnEndpointContent -EndpointName <String> -ProfileName <String> -ResourceGroupName <String>
1818
[-SubscriptionId <String>] -ContentPath <String[]> [-Domain <String[]>] [-DefaultProfile <PSObject>] [-AsJob]
19-
[-NoWait] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
19+
[-NoWait] [-PassThru] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2020
```
2121

2222
### Purge
2323
```
2424
Clear-AzFrontDoorCdnEndpointContent -EndpointName <String> -ProfileName <String> -ResourceGroupName <String>
2525
[-SubscriptionId <String>] -Content <IAfdPurgeParameters> [-DefaultProfile <PSObject>] [-AsJob] [-NoWait]
26-
[-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
26+
[-PassThru] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2727
```
2828

2929
### PurgeViaIdentityExpanded
3030
```
3131
Clear-AzFrontDoorCdnEndpointContent -InputObject <ICdnIdentity> -ContentPath <String[]> [-Domain <String[]>]
32-
[-DefaultProfile <PSObject>] [-AsJob] [-NoWait] [-PassThru] [-WhatIf]
32+
[-DefaultProfile <PSObject>] [-AsJob] [-NoWait] [-PassThru] [-ProgressAction <ActionPreference>] [-WhatIf]
3333
[-Confirm] [<CommonParameters>]
3434
```
3535

3636
### PurgeViaIdentity
3737
```
3838
Clear-AzFrontDoorCdnEndpointContent -InputObject <ICdnIdentity> -Content <IAfdPurgeParameters>
39-
[-DefaultProfile <PSObject>] [-AsJob] [-NoWait] [-PassThru] [-WhatIf]
39+
[-DefaultProfile <PSObject>] [-AsJob] [-NoWait] [-PassThru] [-ProgressAction <ActionPreference>] [-WhatIf]
4040
[-Confirm] [<CommonParameters>]
4141
```
4242

@@ -217,6 +217,21 @@ Accept pipeline input: False
217217
Accept wildcard characters: False
218218
```
219219
220+
### -ProgressAction
221+
{{ Fill ProgressAction Description }}
222+
223+
```yaml
224+
Type: System.Management.Automation.ActionPreference
225+
Parameter Sets: (All)
226+
Aliases: proga
227+
228+
Required: False
229+
Position: Named
230+
Default value: None
231+
Accept pipeline input: False
232+
Accept wildcard characters: False
233+
```
234+
220235
### -ResourceGroupName
221236
Name of the Resource group within the Azure subscription.
222237

src/Cdn/Cdn/help/Disable-AzCdnCustomDomainCustomHttps.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ Disable https delivery of the custom domain.
1616
```
1717
Disable-AzCdnCustomDomainCustomHttps -CustomDomainName <String> -EndpointName <String> -ProfileName <String>
1818
-ResourceGroupName <String> [-SubscriptionId <String>] [-DefaultProfile <PSObject>] [-AsJob] [-NoWait]
19-
[-WhatIf] [-Confirm] [<CommonParameters>]
19+
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2020
```
2121

2222
### DisableViaIdentity
2323
```
2424
Disable-AzCdnCustomDomainCustomHttps -InputObject <ICdnIdentity> [-DefaultProfile <PSObject>] [-AsJob]
25-
[-NoWait] [-WhatIf] [-Confirm] [<CommonParameters>]
25+
[-NoWait] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2626
```
2727

2828
## DESCRIPTION
@@ -146,6 +146,21 @@ Accept pipeline input: False
146146
Accept wildcard characters: False
147147
```
148148
149+
### -ProgressAction
150+
{{ Fill ProgressAction Description }}
151+
152+
```yaml
153+
Type: System.Management.Automation.ActionPreference
154+
Parameter Sets: (All)
155+
Aliases: proga
156+
157+
Required: False
158+
Position: Named
159+
Default value: None
160+
Accept pipeline input: False
161+
Accept wildcard characters: False
162+
```
163+
149164
### -ResourceGroupName
150165
Name of the Resource group within the Azure subscription.
151166

src/Cdn/Cdn/help/Enable-AzCdnCustomDomainCustomHttps.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ Enable https delivery of the custom domain.
1616
```
1717
Enable-AzCdnCustomDomainCustomHttps -InputObject <ICdnIdentity>
1818
-CustomDomainHttpsParameter <ICustomDomainHttpsParameters> [-DefaultProfile <PSObject>] [-AsJob] [-NoWait]
19-
[-WhatIf] [-Confirm] [<CommonParameters>]
19+
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2020
```
2121

2222
### Enable
2323
```
2424
Enable-AzCdnCustomDomainCustomHttps -CustomDomainName <String> -EndpointName <String> -ProfileName <String>
2525
-ResourceGroupName <String> [-SubscriptionId <String>]
2626
-CustomDomainHttpsParameter <ICustomDomainHttpsParameters> [-DefaultProfile <PSObject>] [-AsJob] [-NoWait]
27-
[-WhatIf] [-Confirm] [<CommonParameters>]
27+
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
2828
```
2929

3030
## DESCRIPTION
@@ -171,6 +171,21 @@ Accept pipeline input: False
171171
Accept wildcard characters: False
172172
```
173173
174+
### -ProgressAction
175+
{{ Fill ProgressAction Description }}
176+
177+
```yaml
178+
Type: System.Management.Automation.ActionPreference
179+
Parameter Sets: (All)
180+
Aliases: proga
181+
182+
Required: False
183+
Position: Named
184+
Default value: None
185+
Accept pipeline input: False
186+
Accept wildcard characters: False
187+
```
188+
174189
### -ResourceGroupName
175190
Name of the Resource group within the Azure subscription.
176191

src/Cdn/Cdn/help/Enable-AzFrontDoorCdnProfileMigration.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Commit the migrated Azure Front Door(Standard/Premium) profile..
1515
```
1616
Enable-AzFrontDoorCdnProfileMigration -ProfileName <String> -ResourceGroupName <String>
1717
[-SubscriptionId <String>] [-DefaultProfile <PSObject>] [-AsJob] [-NoWait] [-PassThru]
18-
[-WhatIf] [-Confirm] [<CommonParameters>]
18+
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
1919
```
2020

2121
## DESCRIPTION
@@ -114,6 +114,21 @@ Accept pipeline input: False
114114
Accept wildcard characters: False
115115
```
116116
117+
### -ProgressAction
118+
{{ Fill ProgressAction Description }}
119+
120+
```yaml
121+
Type: System.Management.Automation.ActionPreference
122+
Parameter Sets: (All)
123+
Aliases: proga
124+
125+
Required: False
126+
Position: Named
127+
Default value: None
128+
Accept pipeline input: False
129+
Accept wildcard characters: False
130+
```
131+
117132
### -ResourceGroupName
118133
Name of the Resource group within the Azure subscription.
119134

0 commit comments

Comments
 (0)