{ "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": [ "# Export Existing Azure SQL Server Resources\r\n", "Export notebook that will utilize the ADP resources\r\n", "\r\n", "## Notebook Variables\r\n", "| Line | Variable | Description |\r\n", "| -- | -- | -- |\r\n", "| 1 | AdpSubscription | Azure Subscription ID/Name for the ADP Resource Group # Both RG are assumed to be in the same subscription |\r\n", "| 2 | AdpResourceGroup | Azure Resource Group which contains the ADP Resources | \r\n", "| 3 | SourceResourceGroup | Azure ResourceGroup where the sql server to be exported exists | \r\n", "| 4 | LogicalSQLServerName | Logical sql server name of the sql server to be exported | \r\n", "| 5 | StorageAccount | target storage account to store exported files # any storage account, but must be in the same RG as the ADP resources | \r\n", "| 6 | AdpFunc | |\r\n", "| 7 | AdpBatch | | \r\n", "| 8 | AdpVNET | | " ], "metadata": { "azdata_cell_guid": "b72d138a-566f-4161-b7a6-7264487e446c" } }, { "cell_type": "code", "source": [ "$AdpSubscription = \"\"\r\n", "$AdpResourceGroup = \"\"\r\n", "$SourceResourceGroup= \"\"\r\n", "$LogicalSQLServer = \"\"\r\n", "$StorageAccount = \"\"\r\n", "$AdpFunc = $AdpResourceGroup + \"Control\"\r\n", "$AdpBatch = $AdpResourceGroup.ToLower() + \"batch\"\r\n", "$AdpVNET = $AdpResourceGroup + \"Vnet\"" ], "metadata": { "azdata_cell_guid": "417edc0e-1107-4a27-a4cf-e921f79b3f6a", "tags": [] }, "outputs": [], "execution_count": null }, { "cell_type": "markdown", "source": [ "## Steps\r\n", "Gather input:\r\n", "* [ ] Connect to Azure Subscription\r\n", "* [ ] Choose Resource Group (Read access required)\r\n", "* [ ] Choose Microsoft SQL Server Resources to export\r\n", "* [ ] Choose/Create Migration Storage \r\n", "* [ ] Install Application + Data Portability function (orchestrator service)\r\n", "* [ ] Install ADP Azure Batch processing pipeline\r\n", "* [ ] Store SqlPackage.exe in Migration Storage for orchestrator to hand to Az Batch\r\n", "\r\n", "Execute:\r\n", "* [ ] Check all pre-requisites\r\n", "* [ ] Kick off orchestrator service\r\n", "\r\n", "Monitor:\r\n", "* [ ] Check export status." ], "metadata": { "azdata_cell_guid": "a9da248a-20f1-4574-bd04-7324e70c05a3" } }, { "cell_type": "markdown", "source": [ "## Notebook Functions\r\n", "Defines logical functions for the rest of the notebook. Function blocks are combined in a single cell that can be collapsed for readability or expanded for further examination. Nothing is executed until called later in the notebook. As a result, this cell is a requirement for any of the other cells below it. " ], "metadata": { "azdata_cell_guid": "b70909ed-1863-4882-bacc-a9956993268e" } }, { "cell_type": "code", "source": [ "# Expand cell to view framework\r\n", "\r\n", "function Login-Azure\r\n", "{ \r\n", " # query azure locations to test for existing az login session exists with valid access tocken\r\n", " $azureLocations = az account list-locations -o JSON 2>$null | ConvertFrom-Json\r\n", " \r\n", " if (!$azureLocations){ #If there are no az locations, there is no existing az login session\r\n", " $subscriptions = az login -o JSON | ConvertFrom-Json # Login \r\n", " }\r\n", " else {\r\n", " $subscriptions = az account list -o JSON | ConvertFrom-Json # getting subscriptions for the user to use in gridview\r\n", " }\r\n", "\r\n", " if(![string]::IsNullOrWhiteSpace($AdpSubscription)) #If there is a subscription specified by user in the variables section\r\n", " {\r\n", " $specified_Subscription= az account show --subscription $AdpSubscription -o json |ConvertFrom-Json \r\n", " if (!$specified_Subscription) #if specified subscription is not valid\r\n", " { \r\n", " $currentUser= az ad signed-in-user show --query \"{displayName:displayName,UPN:userPrincipalName}\" -o json|ConvertFrom-Json # get current logged in user infomration\r\n", " Write-Host \"Refer below for the list of subscriptions for logged in account '$($currentUser.UPN)'`n\"\r\n", " az account list --query \"[].{Name:name,SubscriptionID:id}\" -o table # list subscriptions under current logged in account\r\n", " }\r\n", " else { # if specified subscription is valid\r\n", " Write-Output \"Using subscription... '$($specified_Subscription.name)' ... '$($specified_Subscription.id)'\" \r\n", " }\r\n", " }\r\n", " else { # if no subscription is specified, users are given a gridview to select subscription from\r\n", "\r\n", " $selectedSubscription = $subscriptions | Select-Object -Property Name, Id | Out-GridView -PassThru\r\n", " $SubscriptionId = $selectedSubscription.Id\r\n", " $Subscription = $selectedSubscription.Name \r\n", " $AdpSubscription = $subscription \r\n", " Write-Output \"Using subscription... '$AdpSubscription' ... '$SubscriptionId'\" \r\n", " } \r\n", "}\r\n", "\r\n", "function Verify-ADPResources\r\n", "{ \r\n", " [CmdletBinding()]\r\n", " param(\r\n", " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Subscription,\r\n", " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$ADPResourceGroupName,\r\n", " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$FunctionName, \r\n", " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$BatchAccountName,\r\n", " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$VNetName,\r\n", " [Parameter (Mandatory=$false)] [ValidateNotNullOrEmpty()] [string]$ApplicationName=\"SqlPackageWrapper\", \r\n", " [Parameter (Mandatory=$false)] [ValidateNotNullOrEmpty()] [string]$ApplicationPackageVersionName=\"1\",\r\n", " [Parameter (Mandatory=$false)] [ValidateNotNullOrEmpty()] [string]$SubNetName=\"default\" \r\n", " ) \r\n", "\r\n", "# validate Subscription\r\n", "$specified_Subscription= az account show --subscription $Subscription -o json | ConvertFrom-Json\r\n", "if(!$specified_Subscription){\r\n", " $currentUser= az ad signed-in-user show --query \"{displayName:displayName,UPN:userPrincipalName}\" -o json|ConvertFrom-Json # get current logged in user information\r\n", " Write-Host \"Refer below for the list of subscriptions for logged in account '$($currentUser.UPN)'`n\"\r\n", " az account list --query \"[].{Name:name,SubscriptionID:id}\" -o table # list subscriptions under current logged in account\r\n", " return } \r\n", "# validate ResourceGroup \r\n", "$specified_ResourceGroup= az group show -n $ADPResourceGroupName --subscription $Subscription -o json | ConvertFrom-Json\r\n", "if(!$specified_ResourceGroup) { \r\n", " return\r\n", " } \r\n", "\r\n", "$Installed = [ordered]@{} # ordered hash to store status of installation\r\n", "$countError=0\r\n", "\r\n", "#Verify if VNet exists \r\n", "$specified_VNet= az network vnet show -n $VNetName -g $ADPResourceGroupName --subscription $Subscription -o JSON 2>$null |ConvertFrom-Json \r\n", "if(!$specified_VNet) {\r\n", " $Installed['VNET']=\"Not Found\"\r\n", " $countError++\r\n", "} \r\n", "else { \r\n", " $existingVnetSubnet = az network vnet subnet show -n $SubNetName --vnet-name $VNetName -g $ADPResourceGroupName --subscription $Subscription -o JSON 2>$null |ConvertFrom-Json\r\n", " if(!$existingVnetSubnet){\r\n", " $Installed['VNET']=\"Default Subnet under\"+ $VNetName + \"Not Found\"\r\n", " $countError++\r\n", " }\r\n", " else {\r\n", " $Installed['VNET']=\"Installed\"\r\n", " }\r\n", " }\r\n", "\r\n", "#Verify if FunctionApp Exists\r\n", "$specified_FunctionApp = az functionapp show -n $FunctionName -g $ADPResourceGroupName --subscription $Subscription -o JSON 2>$null | ConvertFrom-Json\r\n", "if(!$specified_FunctionApp)\r\n", "{\r\n", " $Installed['FunctionApp']=\"Not Installed\"\r\n", " $countError++\r\n", "}\r\n", "else\r\n", "{\r\n", " $Installed['FunctionApp']=\"Installed\"\r\n", "} \r\n", "\r\n", "#check if Batch account exists\r\n", "$specified_BatchAccount = az batch account show -n $BatchAccountName -g $ADPResourceGroupName --subscription $Subscription -o JSON 2>$null | ConvertFrom-Json\r\n", "if(!$specified_BatchAccount)\r\n", "{\r\n", " $Installed['Batch']=\"Not Installed\"\r\n", " $countError++\r\n", "}\r\n", "else\r\n", "{\r\n", " $appPackageInstalled = az batch application package show --application-name $ApplicationName --version-name $ApplicationPackageVersionName -n $BatchAccountName -g $ADPResourceGroupName --subscription $Subscription -o JSON 2>$null | ConvertFrom-Json\r\n", " $connectedToStorage= $specified_BatchAccount.autoStorage \r\n", " if($connectedToStorage -and $appPackageInstalled){ # BatchAccount connected to storageaccount and applicationpackage is installed\r\n", " $Installed['Batch']=\"Installed\"\r\n", " $Installed['Batch_ApplicationPackage']=\"Installed\"\r\n", " $Installed['Batch_StorageAccount']=\"Connected to storage- \"+$connectedToStorage.storageAccountId.Split(\"/\")[-1]\r\n", " }\r\n", " if(!$connectedToStorage)\r\n", " {\r\n", " $Installed['Batch_StorageAccount']='Not Found'\r\n", " $countError++\r\n", " } \r\n", " if(!$appPackageInstalled)\r\n", " {\r\n", " $Installed['Batch_ApplicationPackage']=\"Not Found\"\r\n", " $countError++\r\n", " } \r\n", "}\r\n", "\r\n", "if ($countError -gt 0){\r\n", " Write-Output \"ADP Resources are not installed correctly. Please refer the list below and use the Bootstrap NB to install ADP Resources\"\r\n", "}\r\n", "$Installed\r\n", "if ($countError -eq 0){\r\n", " Write-Output \"`nFound all ADP Resources.\"\r\n", "}\r\n", "}\r\n", "\r\n", "function Prepare-InputForExportFunction\r\n", "{ \r\n", " [CmdletBinding()]\r\n", " param(\r\n", " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Subscription,\r\n", " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$ADPResourceGroupName,\r\n", " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$FunctionName, \r\n", " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$BatchAccountName,\r\n", " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$VNetName,\r\n", " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$SourceRGName,\r\n", " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$SqlServerName,\r\n", " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$StorageAccountName\r\n", " )\r\n", " \r\n", " $InputResult = @{}\r\n", " # Build Header \r\n", " ## get Function key\r\n", " $FunctionAppID =az functionapp show -n $FunctionName -g $ADPResourceGroupName --subscription $Subscription --query \"[id]\" -o JSON 2>$null | ConvertFrom-Json\r\n", " $DefaultHostKey = az rest --method post --uri \"$FunctionAppID/host/default/listKeys?api-version=2018-11-01\" --query \"[functionKeys.default]\" -o JSON 2>$null | ConvertFrom-Json\r\n", " ## Build Json Object for Headers\r\n", " $headers = @{\r\n", " 'x-functions-key' = $DefaultHostKey\r\n", " }\r\n", " $InputResult['Header']=$headers\r\n", "\r\n", " # Build string for Function URL \r\n", " $specified_Subscription= az account show --subscription $Subscription -o json |ConvertFrom-Json #Get SpecifiedSubscriptionID\r\n", " $SubscriptionID= $specified_Subscription.id\r\n", " $FunctionUrl = 'https://'+ $FunctionName +'.azurewebsites.net/api/subscriptions/'+ $SubscriptionID +'/resourceGroups/' + $ADPResourceGroupName + '/Export'\r\n", " $InputResult['FunctionURL']=$FunctionUrl\r\n", "\r\n", " # Set parameter variables for Body\r\n", " ## Get BatchAccountURL \r\n", " $specified_Batch = az batch account show -n $BatchAccountName -g $ADPResourceGroupName --subscription $Subscription -o JSON 2>$null | ConvertFrom-Json\r\n", " $BatchAccountURL = 'https://' + $specified_Batch.accountEndpoint \r\n", "\r\n", " ## Get default SubNet ID for specified VNet\r\n", " $specified_VNet_SubNet = az network vnet subnet show -g $ADPResourceGroupName --vnet-name $VNetName -n 'default' --subscription $Subscription -o JSON |ConvertFrom-Json\r\n", " $VNetSubNetID = $specified_VNet_SubNet.id\n", "\n", " ## Create access token to source sql server\n", " $sourceAccessToken = az account get-access-token --resource=https://database.windows.net --query accessToken\n", " $sourceAccessToken\r\n", "\r\n", " ## Build JSon object for Body\r\n", " $Body = @{\r\n", " batchAccountUrl = $BatchAccountURL\r\n", " storageAccountName = $StorageAccountName # any storage account, not neccessarily the one connected to the batch account\r\n", " sourceSqlServerResourceGroupName = $SourceRGName \r\n", " sourceSqlServerName = $SQLServerName \n", " accessToken= $sourceAccessToken\r\n", " VNetSubnetId= $VNetSubNetID\r\n", " }\r\n", " $json = $Body | ConvertTo-Json\r\n", " $InputResult['Body']=$json\r\n", "\r\n", " $InputResult\r\n", "}\r\n", "\r\n", "function Provision-FuncRBAC {\r\n", " [CmdletBinding()]\r\n", " param (\r\n", " [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string]$Subscription,\r\n", " [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string]$ResourceGroupName,\r\n", " [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string]$FunctionName,\r\n", " [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string]$ScopeRGName,\r\n", " [Parameter(Mandatory=$false)][ValidateNotNullOrEmpty()][string]$Role=\"Contributor\"\r\n", " )\r\n", "\r\n", " # Get the scope resource group's ID\r\n", " $scopeID = az group show --resource-group $ScopeRGName --subscription $Subscription --query \"[id]\" -o JSON | ConvertFrom-Json \r\n", " if(!$scopeID) {\r\n", " Write-Output \"Provision-FuncRBAC failed.\" \r\n", " return }\r\n", " else { Write-Output \"Found scope '$ScopeRGName' with ID... '$scopeID'\"\r\n", " }\r\n", "\r\n", " # Get the az function principal id\r\n", " $app_PrincipalID = az functionapp show -n $FunctionName --resource-group $ResourceGroupName --subscription $Subscription --query \"[identity.principalId]\" -o JSON | ConvertFrom-Json \r\n", " if(!$app_PrincipalID) {\r\n", " Write-Output \"Provision-FuncRBAC failed.\" \r\n", " return }\r\n", " else { Write-Output \"Found principal id of Azure function '$FunctionName'... '$app_PrincipalID'\"\r\n", " }\r\n", "\r\n", " # Verify if a role assignment has been created for function\r\n", " $app_RoleAssignmentDefinition= az role assignment list --subscription $Subscription --assignee $app_PrincipalID --scope $scopeID --query \"[].roleDefinitionName\" -o JSON 2>$null | ConvertFrom-Json\r\n", "\r\n", " if($app_RoleAssignmentDefinition -eq $Role)\r\n", " {\r\n", " Write-Output \"Found Role Assignment for Principal ID.. '$app_PrincipalID' with Role.. '$app_RoleAssignmentDefinition' . No work needed\"\r\n", " }\r\n", " else\r\n", " {\r\n", " # Continue to setup RBAC, once we verify an assignment is not setup and all the resources exist\r\n", " Write-Output \"Creating new role assignment by running: 'az functionapp identity assign -n $FunctionName --role $Role -g $ResourceGroupName --scope $scopeID --subscription $Subscription'\"\r\n", " Write-Warning \"If your account does not have the access to assign new roles as Owner or User Access Administrator for the resource group, than you will need to contact your Azure AD Administrator to assign a service principle using the commands above\"\r\n", " az functionapp identity assign -n $FunctionName --role $Role -g $ResourceGroupName --scope $scopeID --subscription $Subscription \r\n", " }\r\n", "}\r\n", "Write-Host \"Helper Functions Created successfully\" " ], "metadata": { "azdata_cell_guid": "af70490a-c6cb-4086-99ff-c3527b4315ed", "tags": [ "hide_input" ] }, "outputs": [], "execution_count": null }, { "cell_type": "markdown", "source": [ "## Connect to Azure Account\r\n", "Run the below cell to login to an Azure account. Be sure to check the Windows Taskbar for a login dialog box underneath the notebook or other windows or by pressing Alt+TAB." ], "metadata": { "azdata_cell_guid": "55f9b3b2-9ce0-4607-9a45-384279f5d16f" } }, { "cell_type": "code", "source": [ "Login-Azure " ], "metadata": { "azdata_cell_guid": "4a577303-83b9-48f8-95ba-e4f74c7440c9" }, "outputs": [], "execution_count": null }, { "cell_type": "markdown", "source": [ "## Verify ADP Resources \r\n", "Verify if ADP resources exists in specified Resource Group" ], "metadata": { "azdata_cell_guid": "a7e4bef8-3db6-4e68-8eb8-5a1feb4b3ac5" } }, { "cell_type": "code", "source": [ "Verify-ADPResources -Subscription $AdpSubscription -ADPResourceGroupName $AdpResourceGroup `\r\n", " -BatchAccountName $AdpBatch -FunctionName $AdpFunc -VNetName $AdpVNET " ], "metadata": { "azdata_cell_guid": "8185f2ea-d368-42c5-9246-bc1871affc63" }, "outputs": [], "execution_count": null }, { "cell_type": "markdown", "source": [ "## Verify RBAC of Azure Function\r\n", "Roles based access control is a function of Azure that assigns services to a role with a specific access scope (or area of access). The ADP Orchestrator function requires Contributor access over the Resource Group where the SQL Server to be exported exists. The function below will attempt to create the role assignment. Any user executing this notebook will need to have Owner or User Access Administrator permissions to the Resource Group to assign the permission. Otherwise, contact your Azure AD Administrator. " ], "metadata": { "azdata_cell_guid": "e919b0e3-34d6-40aa-8b29-cf92b943954c" } }, { "cell_type": "code", "source": [ "Provision-FuncRBAC -FunctionName $AdpFunc -ScopeRGName $SourceResourceGroup -ResourceGroupName $AdpResourceGroup -Subscription $AdpSubscription" ], "metadata": { "azdata_cell_guid": "7678701e-ec40-43d9-baff-fd1cdabba1cd" }, "outputs": [], "execution_count": null }, { "cell_type": "markdown", "source": [ "## Verify Access to Source Server\r\n", "\r\n", "Before scheduling the export, validate the source SQL Server is accessible." ], "metadata": { "azdata_cell_guid": "e8310d46-b7ed-4012-a993-1515c2d17e66" } }, { "cell_type": "code", "source": [ "$sqlServer = az sql server show --name $LogicalSQLServerName --resource-group $SourceResourceGroup --subscription $AdpSubscription -o JSON | ConvertFrom-JSON\r\n", "if ($sqlServer)\r\n", "{\r\n", " Write-Host \"Source SQL Server: \" $sqlServer.name\r\n", " if ($sqlServer.state -eq \"Ready\")\r\n", " {\r\n", " Write-Host \"State: Ready\"\r\n", " }\r\n", " else\r\n", " {\r\n", " Write-Host \"ERROR: Source server is not in Ready state. Current state is: \" $sqlServer.state\r\n", " }\r\n", "\r\n", " $sqlAzureAdmin = az sql server ad-admin list --server $LogicalSQLServerName --resource-group $SourceResourceGroup --subscription $AdpSubscription -o JSON | ConvertFrom-JSON\r\n", " if ($sqlAzureAdmin)\r\n", " {\r\n", " Write-Host \"Azure AD admin set to\" $sqlAzureAdmin.login\r\n", " Write-Host \"SUCCESS: source server accessible and properly configured.\"\r\n", " }\r\n", " else\r\n", " {\r\n", " Write-Host \"ERROR: Source server has no Azure AD administrator configured. The Data Portability solution requires Azure Active Directory to be configured on source servers to provide secure access.\"\r\n", " }\r\n", "\r\n", "}\r\n", "else \r\n", "{\r\n", " Write-Host \"ERROR: Source server \" $sqlServer.name \"not found or current account lacks access to resource.\"\r\n", " Write-Host \"Validate input settings:\"\r\n", " Write-Host \"Resource group: \" $SourceResourceGroup\r\n", " Write-Host \"Subscription: \" $AdpSubscription\r\n", "}" ], "metadata": { "azdata_cell_guid": "5e217942-b9b0-47d0-a9b7-79b5db93ea55" }, "outputs": [], "execution_count": null }, { "cell_type": "markdown", "source": [ "## Prepare input variable for Orchestrator Export Function" ], "metadata": { "azdata_cell_guid": "bc9acbcc-f5e1-4642-b1e3-677fca704dfc" } }, { "cell_type": "code", "source": [ "$InputForExportFunction = Prepare-InputForExportFunction -Subscription $AdpSubscription -ADPResourceGroupName $AdpResourceGroup `\r\n", " -BatchAccountName $AdpBatch -FunctionName $AdpFunc -VNetName $AdpVNET -SourceRGName $SourceResourceGroup `\r\n", " -SqlServerName $LogicalSQLServerName -StorageAccountName $StorageAccount\r\n", "Write-Host \"Setting parameter variables for Export Function Call...\"\r\n", "$InputForExportFunction.Header\r\n", "$InputForExportFunction.FunctionURL\r\n", "$InputForExportFunction.Body" ], "metadata": { "azdata_cell_guid": "9e6f142c-3295-4c12-9b9f-588c7c283b2d" }, "outputs": [], "execution_count": null }, { "cell_type": "markdown", "source": [ "## Start Export of SQL Server \r\n", "Run the cell to start export operation of specified sql server" ], "metadata": { "azdata_cell_guid": "d6a9e5c3-bd3c-4f06-8adc-c7751e33b4cf" } }, { "cell_type": "code", "source": [ "$ExportResponse = Invoke-RestMethod -Method 'Post' -Headers $InputForExportFunction.Header -Uri $InputForExportFunction.FunctionURL -Body $InputForExportFunction.Body -ContentType 'application/json'\r\n", "$ExportResponse" ], "metadata": { "azdata_cell_guid": "2e0167f6-b91c-4d65-a6e6-a1ef0bada436" }, "outputs": [], "execution_count": null }, { "cell_type": "markdown", "source": [ "## Get Status of Export Operation\r\n", "Run the cell to get export operation status" ], "metadata": { "azdata_cell_guid": "34812090-faa7-4375-8e76-72defea6d57a" } }, { "cell_type": "code", "source": [ "$statusCheckResponse = Invoke-RestMethod -Method 'Get' -Uri $ExportResponse.statusQueryGetUri\r\n", "\r\n", "\r\n", "Write-Host \"Orchestrator Request: \" $statusCheckResponse.name\r\n", "Write-Host \"`tOrchestrator Status: \" $statusCheckResponse.runtimeStatus\r\n", "\r\n", "$outputParams = $statusCheckResponse.output \r\n", "if ($outputParams)\r\n", "{\r\n", " $batchJobID = $outputParams.Item2[0]\r\n", " $containerUrl = $outputParams.Item2[1]\r\n", "\r\n", " Write-Host \"`tCreated Export Batch Job ID: \" $batchJobId\r\n", " Write-Host \"`tExport container URL: \" $containerUrl\r\n", "\r\n", " $azBatchLogin = az batch account login --name $AdpBatch --resource-group $AdpResourceGroup -o JSON | ConvertFrom-Json\r\n", " $jobStatus = az batch job show --job-id $batchJobID -o JSON | ConvertFrom-Json\r\n", " Write-Host \"Export Job running on Pool: \" $jobStatus.poolInfo.poolId\r\n", " Write-Host \"`tExport Request Status: \" $jobStatus.state\r\n", "\r\n", " $taskList = az batch task list --job-id $batchJobId -o JSON | ConvertFrom-Json\r\n", " if ($taskList)\r\n", " {\r\n", " foreach ($task in $taskList)\r\n", " {\r\n", " Write-Host \"`tDatabase Export Task ID: \" $task.id \r\n", " Write-Host \"`t`tStatus: \" $task.state\r\n", " $taskExecution = $task.executionInfo\r\n", " if ($taskExecution)\r\n", " {\r\n", " Write-Host \"`t`tResult: \" $taskExecution.result\r\n", " }\r\n", " }\r\n", " }\r\n", "}" ], "metadata": { "azdata_cell_guid": "de949b83-195d-455b-ab63-5607cad7c9dd" }, "outputs": [], "execution_count": null } ] }