This repository contains Python and PowerShell scripts to check whether Azure resources can be moved to a different subscription, resource group, or region.
Moving Azure resources from one subscription, resource group, or region to another can be a complex task, and requires careful planning and execution. This repository provides Python and PowerShell scripts that can help you check whether a given set of Azure resources can be moved to a different subscription, resource group, or region.
The Python script fetch_non_movable_resources.py scrapes Microsoft Doc's GitHub page for a list of non-movable resources, including resource group and region move support, and saves it to a JSON file named NonMovableResources.json. The PowerShell script Test-AzResourceMove.ps1 imports this JSON file into an array and checks each resource in the source subscription against this list to determine whether it can be moved or not. The result of the check is then written to a CSV file, which can be used to help plan and execute the resource move.
- Azure Subscription
- Python 3.7 or higher (for Python Script)
- PowerShell 5.1 or higher (for PowerShell Script)
- Azure PowerShell module
- requests, re, json (for Python Script)
The fetch_non_movable_resources.py script is written in Python and uses the requests module to scrape Microsoft Doc's GitHub page for a list of non-movable resources, including resource group and region move support. It then saves the list to a JSON file named NonMovableResources.json.
To run the Python script, follow these steps:
- Clone this repository to your local machine.
- Open a terminal or command prompt and navigate to the root directory of the repository.
- Run the following command to install the required Python packages:
pip install -r requirements.txt - Run the following command to execute the script:
python fetch_non_movable_resources.py - The script will generate a JSON file named
NonMovableResources.jsonin the root directory of the repository.
The Test-AzResourceMove.ps1 script is written in PowerShell and uses the Azure PowerShell module to retrieve the list of resources in the source subscription. It then checks each resource against the list of non-movable resources in the NonMovableResources.json file, and writes the result of the check to a CSV file.
To run the PowerShell script, follow these steps:
- Clone this repository to your local machine.
- Open a PowerShell terminal and navigate to the root directory of the repository.
- Run the following command to execute the script:
.\Test-AzResourceMove.ps1 - The script will generate a CSV file named
Test-AzResourceMove.csvin thec:\tempdirectory.
Contributions are welcome! Please feel free to open an issue or submit a pull request with any improvements or bug fixes.