Azure / App-Service-Migration-Assistant

Azure Websites Migration Assistant for Windows is a tool that allows customers to move their existing sites hosted on IIS servers into the cloud on Azure App Service. For more information check out https://appmigration.microsoft.com .
https://appmigration.microsoft.com
MIT License
74 stars 60 forks source link

Support govCloud with Powershell Migration scripts. #79

Closed DPD-30 closed 6 months ago

DPD-30 commented 1 year ago

The currently published "App Service migration assistant for PowerShell scripts" https://github.com/Azure/App-Service-Migration-Assistant/wiki/PowerShell-Scripts do not support working with Azure Government. They work fine against Azure commercial but have not method to switch to or detect if you are using Azure government. I was able to modify the scripts to make this work.

Issue 1 no option to provide environment for for connect-azacount Issue 2 hard coded url for management api. "https://management.azure.com"

Investigative information

Please provide the following:

Repro steps

Provide the steps required to reproduce the problem:

Simple test

  1. Run SampleServerMigration.ps1
  2. When prompted login using Azure Government Credentials.
  3. unable to login as it directs you to Azure Government.

Test 2 Existing AZ login

  1. Run connect-azaccount -Environment AzureUSGovernment
  2. Run SampleServerMigration.ps1
  3. When prompted login using Azure Government Credentials. (Success)
  4. Error 404 when validating Site URLS caused in line 242 of MigrationHelperFunctions.psm1

Expected behavior

Expected behavior is for the code to either detect the environment or allow the user to select the environment.

Actual behavior

All azure commands are run against the Azure commercial environment in Simple Test steps above. For test 2 existing AZ login the validation of web site urls fail as it is run against the "https://management.azure.com" address. Which is hard coded in line 242 of MigrationHelperFunctions.psm1

Known workarounds

  1. modify code in MigrationHelperFunctions.psm1

  2. Replace line 242 $Uri = "https://management.azure.com/subscriptions/$AzureSubscriptionId/providers/microsoft.web/checknameavailability?api-version=2019-08-01" ---- With --- $context = get-azcontext
    $Uri = "$($context.Environment.ResourceManagerUrl)/subscriptions/$AzureSubscriptionId/providers/microsoft.web/checknameavailability?api-version=2019-08-01"

  3. Remove code signing signature at bottom of the file.

  4. Save file

  5. Run below to reload the module Import-Module .\MigrationHelperFunctions.psm1 -force

  6. Run connect-azaccount -Environment AzureUSGovernment

  7. Run any of the App Service migration assistant Powershell scripts they should function as expected with any azure environment now.

krolson commented 1 year ago

Hi @DPD-30, Thank you very much for posting this and how you worked around it for others who might run into the same limitation. It's true that the current release is only supported for public cloud, but we can incorporate the ability to target any cloud in the next release - I've tagged this as an enhancement and will leave this open until that time so that others can see your notes.

krolson commented 6 months ago

@DPD-30 Just an update that the latest version of the PS scripts (1.0.2) allows for pointing to AzureUSGovernment cloud by changing only the configuration settings.json file (notes: https://github.com/Azure/App-Service-Migration-Assistant/wiki/Release-Notes). Thank you for raising this as an issue!