You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Cdn/Cdn.Autorest/custom/Start-AzFrontDoorCdnProfilePrepareMigration.ps1
+34-24Lines changed: 34 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -238,12 +238,16 @@ function Start-AzFrontDoorCdnProfilePrepareMigration {
238
238
throw"MigrationWebApplicationFirewallMapping parameter instance should be equal to the number of WAF policy instance in the profile."
239
239
}
240
240
241
-
if (($PSBoundParameters.ContainsKey('IdentityType')) -ne ($allPoliciesWithVault.count-gt0)) {
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-gt0) -and!($PSBoundParameters.ContainsKey('IdentityType')))
244
+
{
245
+
throw"IdentityType parameter should be provided when the front door has Customer Certificates."
243
246
}
244
-
Write-Host("The parameters have been successfully validated.")
245
247
246
-
# Deal with Waf policy
248
+
Write-Host("The parameters have been validated successfully.")
249
+
250
+
# Step1: Deal with Waf policy
247
251
if ($PSBoundParameters.ContainsKey('MigrationWebApplicationFirewallMapping')) {
248
252
Write-Host("Starting to configure WAF policy upgrades.")
249
253
@@ -287,7 +291,7 @@ function Start-AzFrontDoorCdnProfilePrepareMigration {
287
291
Write-Host("WAF policy upgrades have been configured successfully.")
288
292
}
289
293
290
-
# Create AFDx Profile
294
+
#Step2: Create AFDx Profile
291
295
# 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)
292
296
Write-Host("Your new Front Door profile is being created. Please wait until the process has finished completely. This may take several minutes.")
293
297
$null=$PSBoundParameters.Remove('IdentityType')
@@ -302,9 +306,8 @@ function Start-AzFrontDoorCdnProfilePrepareMigration {
302
306
303
307
Write-Host("Your new Front Door profile with the configuration has been successfully created.")
304
308
305
-
# Deal with MSI parameter
306
-
# if ($PSBoundParameters.ContainsKey('IdentityType')) {
307
-
if ($allPoliciesWithVault.count-gt0) {
309
+
# Step 3: Deal with MSI parameter
310
+
if (${IdentityType}) {
308
311
Write-Host("Starting to enable managed identity.")
309
312
310
313
# Waiting for results of profile created return
@@ -318,7 +321,7 @@ function Start-AzFrontDoorCdnProfilePrepareMigration {
# 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'.
# 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'.
0 commit comments