{ "metadata": { "kernelspec": { "name": "powershell", "display_name": "PowerShell" }, "language_info": { "name": "powershell", "codemirror_mode": "shell", "mimetype": "text/x-sh", "file_extension": ".ps1" } }, "nbformat_minor": 2, "nbformat": 4, "cells": [ { "cell_type": "markdown", "source": [ "# 0. Preparing the Credential" ], "metadata": { "azdata_cell_guid": "140ce3a4-9596-47b5-ad22-87c3bd2057f6" } }, { "cell_type": "code", "source": [ "$functionKey = 'yourAzureFunctionKey'\r\n", "$Login = 'yourSqlServerLogin'\r\n", "$Password = 'yourSqlServerPassword'\r\n", "\r\n", "$headers = @{\r\n", " 'x-functions-key' = $functionKey\r\n", "}" ], "metadata": { "azdata_cell_guid": "36fa6902-7640-462d-bc2e-6b49e9aaa0d9", "tags": [] }, "outputs": [], "execution_count": null }, { "cell_type": "markdown", "source": [ "# 1. Calling the ADP Orchestrator (Export)\r\n", "## 1.1 Submit the Export request to the source Azure SQL Server." ], "metadata": { "azdata_cell_guid": "40c4517b-8145-4af1-bbbb-3be3b9b9a8a0" } }, { "cell_type": "code", "source": [ "$Url = 'https://adpcontrol.azurewebsites.net/api/subscriptions/0009fc4d-e310-4e40-8e63-c48a23e9cdc1/resourceGroups/seanadp01/Export'\n", "\n", "$Body = @{\n", " batchAccountUrl = 'https://adp.eastus.batch.azure.com'\n", " storageAccountName = 'adp01batch'\n", " sourceSqlServerResourceGroupName = 'SeanADP01Source'\n", " sourceSqlServerName = 'adpsvr01'\n", " userName = $Login \n", " password = $Password \n", "}\n", "\n", "$json = $Body | ConvertTo-Json\n", "$exportResponse = Invoke-RestMethod -Method 'Post' -Headers $headers -Uri $Url -Body $json -ContentType 'application/json'\n", "$exportResponse" ], "metadata": { "azdata_cell_guid": "7e1d3261-5e61-4106-8063-7cd58ffd0cf1", "tags": [] }, "outputs": [], "execution_count": null }, { "cell_type": "markdown", "source": [ "## 1.2 Getting the Operation Status" ], "metadata": { "azdata_cell_guid": "52204c15-abad-4ce5-8629-d290332f730b" } }, { "cell_type": "code", "source": [ "Invoke-RestMethod -Method 'Get' -Uri $exportResponse.statusQueryGetUri" ], "metadata": { "azdata_cell_guid": "a0ba1261-3a26-4168-b149-1b9e44939432", "tags": [ "hide_input" ] }, "outputs": [], "execution_count": null }, { "cell_type": "markdown", "source": [ "# 2. Calling the ADP Orchestrator (Import)\r\n", "## 2.1 Submit the Import request to the target Azure SQL Server." ], "metadata": { "azdata_cell_guid": "2c862275-c380-476a-ab3d-a9aacdca963b" } }, { "cell_type": "code", "source": [ "$Url = 'https://adpcontrol.azurewebsites.net/api/subscriptions/0009fc4d-e310-4e40-8e63-c48a23e9cdc1/resourceGroups/seanadp01/Import'\r\n", "$Body = @{\r\n", " batchAccountUrl = 'https://adp.eastus.batch.azure.com'\r\n", " storageAccountName = 'adp01batch'\r\n", " containerName = 'adpsvr01-0428061710'\r\n", " targetSqlServerResourceGroupName = 'SeanADP01Target'\r\n", " targetSqlServerName = 'adpsvr03'\r\n", " userName = $Login \r\n", " password = $Password \r\n", "}\r\n", "\r\n", "$json = $Body | ConvertTo-Json\r\n", "$importResponse = Invoke-RestMethod -Method 'Post' -Headers $headers -Uri $Url -Body $json -ContentType 'application/json'\r\n", "$importResponse" ], "metadata": { "azdata_cell_guid": "315859aa-e452-4ab3-acb5-92c7c8bd5857", "tags": [] }, "outputs": [], "execution_count": null }, { "cell_type": "markdown", "source": [ "## 2.2 Getting the Operation Status" ], "metadata": { "azdata_cell_guid": "5da3293b-7d10-4315-8106-79e56cd657ea" } }, { "cell_type": "code", "source": [ "Invoke-RestMethod -Method 'Get' -Uri $importResponse.statusQueryGetUri" ], "metadata": { "azdata_cell_guid": "328d3a27-4cdf-4623-a8c5-8230487efbed", "tags": [ "hide_input" ] }, "outputs": [], "execution_count": null } ] }