Use the Microsoft Azure Command-Line interface (CLI)
- Last UpdatedNov 13, 2025
- 1 minute read
- PI System
- PI Server 2024 R2
- PI Server
You can migrate a PI AF database to Azure SQL Database or Azure Managed Instance using the Azure Command-Line interface (CLI).
-
Download and install the Azure CLI utility. See Azure Command-Line Interface (CLI) documentation for install instructions.
-
Open PowerShell in Administrative mode.
-
At the command prompt, enter az login.
-
Enter the following command and parameters:
az account set --subscription <Subscription-id>
-
Optional: If you do not have a pre-configured database migration service and self-hosted Integration Runtime agent, enter the the following commands to configure the service and agent:
az datamigration sql-service create --resource-group "MyResourceGroup" --sql-migration-service-name "MySqlMigrationService" --location "EastUS2"
$authKey1 = az datamigration sql-service list-auth-key --resource-group "MyResourceGroup" --sql-migration-service-name "MySqlMigrationService" --query "authKey1"
az datamigration register-integration-runtime --auth-key $authKey1 --ir-path "C:\Users\user\Downloads\IntegrationRuntime.msi"
az datamigration register-integration-runtime --auth-key $authKey1
-
To initiate the database migration, enter the following commands:
az datamigration sql-db create
Code example for Azure CLI
az datamigration sql-db create `
--migration-service "/subscriptions/MySubscriptionID/resourceGroups/MyGroup/providers/Microsoft.DataMigration/SqlMigrationServices/MyService" `
--scope "/subscriptions/MySubscriptionID/resourceGroups/MyGroup/providers/Microsoft.Sql/servers/labserver" `
--source-database-name "AdventureWorks" `
--source-sql-connection authentication="SQLAuthentication" data-source="LABSERVER.MICROSOFT.COM" password="password" user-name="user" `
--target-sql-connection authentication="SQLAuthentication" data-source="labserver.database.windows.net" password="password" user-name="user" `
--resource-group "MyGroup" --sqldb-instance-name "labserver" --target-db-name AdventureWorksTarget