From 0108da2a247f90cfbbc5d187828e4db3483aa845 Mon Sep 17 00:00:00 2001 From: Christopher C <37060219+cavonac@users.noreply.github.com> Date: Tue, 23 Feb 2021 13:36:09 -0800 Subject: [PATCH] Cavonac/params (#14264) * visual consistent added variable table * typo * update variables and code * variable descriptions * typos * typo * added next steps * identifying param cells * updates to readme and removing orphaned notebooks Co-authored-by: Alex Ma --- .../compatibility-assessment.ipynb | 8 +- .../Assessments/sql-server-assessment.ipynb | 5 +- .../data-portability/export-sql-server.ipynb | 7 +- .../data-portability/import-sql-server.ipynb | 7 +- .../content/data-portability/setup-adp.ipynb | 7 +- .../content/hadr/backup-to-blob.ipynb | 8 +- .../content/hadr/configure-failover.ipynb | 6 +- .../networking/download-VpnClient.ipynb | 8 +- .../content/networking/p2svnet-creation.ipynb | 8 +- .../content/networking/s2svnet-creation.ipynb | 8 +- .../offline-migration/db-to-SQLDB.ipynb | 5 +- .../offline-migration/instance-to-VM.ipynb | 4 +- .../provisioning/create-sqldb-azCli.ipynb | 239 -------- .../content/provisioning/create-sqldb.ipynb | 185 +++--- .../content/provisioning/create-sqlmi.ipynb | 8 +- .../provisioning/create-sqlvm-azCli.ipynb | 557 ------------------ .../content/provisioning/create-sqlvm.ipynb | 4 +- .../notebooks/hybridbook/content/readme.md | 24 +- 18 files changed, 202 insertions(+), 896 deletions(-) delete mode 100644 extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqldb-azCli.ipynb delete mode 100644 extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqlvm-azCli.ipynb diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/Assessments/compatibility-assessment.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/Assessments/compatibility-assessment.ipynb index dde714ebdb..8f9ea0940c 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/Assessments/compatibility-assessment.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/Assessments/compatibility-assessment.ipynb @@ -2,7 +2,8 @@ "metadata": { "kernelspec": { "name": "powershell", - "display_name": "PowerShell" + "display_name": "PowerShell", + "language": "powershell" }, "language_info": { "name": "powershell", @@ -44,7 +45,10 @@ "$ResultPath = \"\"" ], "metadata": { - "azdata_cell_guid": "d81972c1-3b0b-47d9-b8a3-bc5ab4001a34" + "azdata_cell_guid": "d81972c1-3b0b-47d9-b8a3-bc5ab4001a34", + "tags": [ + "parameters" + ] }, "outputs": [], "execution_count": null diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/Assessments/sql-server-assessment.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/Assessments/sql-server-assessment.ipynb index 49cd6099d4..e9d2892626 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/Assessments/sql-server-assessment.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/Assessments/sql-server-assessment.ipynb @@ -42,7 +42,10 @@ "$OutputTable = \"\"" ], "metadata": { - "azdata_cell_guid": "db21129e-9bda-4db9-8d61-d2b264a3cad8" + "azdata_cell_guid": "db21129e-9bda-4db9-8d61-d2b264a3cad8", + "tags": [ + "parameters" + ] }, "outputs": [], "execution_count": null diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/data-portability/export-sql-server.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/data-portability/export-sql-server.ipynb index 22de4343f3..2128b8c7c8 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/data-portability/export-sql-server.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/data-portability/export-sql-server.ipynb @@ -2,7 +2,8 @@ "metadata": { "kernelspec": { "name": "powershell", - "display_name": "PowerShell" + "display_name": "PowerShell", + "language": "powershell" }, "language_info": { "name": "powershell", @@ -50,7 +51,9 @@ ], "metadata": { "azdata_cell_guid": "417edc0e-1107-4a27-a4cf-e921f79b3f6a", - "tags": [] + "tags": [ + "parameters" + ] }, "outputs": [], "execution_count": null diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/data-portability/import-sql-server.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/data-portability/import-sql-server.ipynb index b2b968b4a0..9f0a965eef 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/data-portability/import-sql-server.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/data-portability/import-sql-server.ipynb @@ -2,7 +2,8 @@ "metadata": { "kernelspec": { "name": "powershell", - "display_name": "PowerShell" + "display_name": "PowerShell", + "language": "powershell" }, "language_info": { "name": "powershell", @@ -80,7 +81,9 @@ ], "metadata": { "azdata_cell_guid": "01888595-0d1c-445b-ba85-dd12caa30192", - "tags": [] + "tags": [ + "parameters" + ] }, "outputs": [], "execution_count": null diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/data-portability/setup-adp.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/data-portability/setup-adp.ipynb index b5d33f0c6f..0bf1d69ab6 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/data-portability/setup-adp.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/data-portability/setup-adp.ipynb @@ -2,7 +2,8 @@ "metadata": { "kernelspec": { "name": "powershell", - "display_name": "PowerShell" + "display_name": "PowerShell", + "language": "powershell" }, "language_info": { "name": "powershell", @@ -77,7 +78,9 @@ ], "metadata": { "azdata_cell_guid": "5896a9a8-5ba8-4888-967a-10c3ceaccf12", - "tags": [] + "tags": [ + "parameters" + ] }, "outputs": [], "execution_count": null diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/hadr/backup-to-blob.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/hadr/backup-to-blob.ipynb index ea555d0ae1..b96078d201 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/hadr/backup-to-blob.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/hadr/backup-to-blob.ipynb @@ -2,7 +2,8 @@ "metadata": { "kernelspec": { "name": "powershell", - "display_name": "PowerShell" + "display_name": "PowerShell", + "language": "powershell" }, "language_info": { "name": "powershell", @@ -58,7 +59,10 @@ "$SqlPath = \"sqlserver:\\sql\\$($env:COMPUTERNAME)\" #This script will generate Sql Path" ], "metadata": { - "azdata_cell_guid": "7ad525ec-4993-4e14-9677-4f77433b2123" + "azdata_cell_guid": "7ad525ec-4993-4e14-9677-4f77433b2123", + "tags": [ + "parameters" + ] }, "outputs": [], "execution_count": null diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/hadr/configure-failover.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/hadr/configure-failover.ipynb index 4f6dcb75be..c8c7134c2c 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/hadr/configure-failover.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/hadr/configure-failover.ipynb @@ -88,7 +88,9 @@ ], "metadata": { "azdata_cell_guid": "7ad525ec-4993-4e14-9677-4f77433b2123", - "tags": [] + "tags": [ + "parameters" + ] }, "outputs": [], "execution_count": null @@ -387,4 +389,4 @@ } } ] -} +} \ No newline at end of file diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/networking/download-VpnClient.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/networking/download-VpnClient.ipynb index c6df5c696c..22069e472b 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/networking/download-VpnClient.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/networking/download-VpnClient.ipynb @@ -2,7 +2,8 @@ "metadata": { "kernelspec": { "name": "powershell", - "display_name": "PowerShell" + "display_name": "PowerShell", + "language": "powershell" }, "language_info": { "name": "powershell", @@ -35,7 +36,10 @@ "$filePathForCert = \"\" # Path of the certificate file. For example 'D:\\Downloads\\rootcert2.cer'" ], "metadata": { - "azdata_cell_guid": "8eab9fb0-1e66-4a34-8e32-cf0644b157d9" + "azdata_cell_guid": "8eab9fb0-1e66-4a34-8e32-cf0644b157d9", + "tags": [ + "parameters" + ] }, "outputs": [], "execution_count": null diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/networking/p2svnet-creation.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/networking/p2svnet-creation.ipynb index dae6b77d2d..5ef32d87df 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/networking/p2svnet-creation.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/networking/p2svnet-creation.ipynb @@ -2,7 +2,8 @@ "metadata": { "kernelspec": { "name": "powershell", - "display_name": "PowerShell" + "display_name": "PowerShell", + "language": "powershell" }, "language_info": { "name": "powershell", @@ -62,7 +63,10 @@ "$GwIPConf1 = \"\" # Gateway IP Config name of your choice(It would be alphanumeric case insensitive)" ], "metadata": { - "azdata_cell_guid": "424c911f-fb75-44f9-902d-c06dedf9eaf6" + "azdata_cell_guid": "424c911f-fb75-44f9-902d-c06dedf9eaf6", + "tags": [ + "parameters" + ] }, "outputs": [], "execution_count": null diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/networking/s2svnet-creation.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/networking/s2svnet-creation.ipynb index 3ccd0712d5..870d961a24 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/networking/s2svnet-creation.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/networking/s2svnet-creation.ipynb @@ -2,7 +2,8 @@ "metadata": { "kernelspec": { "name": "powershell", - "display_name": "PowerShell" + "display_name": "PowerShell", + "language": "powershell" }, "language_info": { "name": "powershell", @@ -73,7 +74,10 @@ "$ConnectionName = \"\"" ], "metadata": { - "azdata_cell_guid": "f883288a-fc6a-4b0f-9215-6b771dc72b8d" + "azdata_cell_guid": "f883288a-fc6a-4b0f-9215-6b771dc72b8d", + "tags": [ + "parameters" + ] }, "outputs": [], "execution_count": null diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/offline-migration/db-to-SQLDB.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/offline-migration/db-to-SQLDB.ipynb index a65ea8f63d..a2264827d1 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/offline-migration/db-to-SQLDB.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/offline-migration/db-to-SQLDB.ipynb @@ -76,7 +76,10 @@ "#>" ], "metadata": { - "azdata_cell_guid": "2624afc0-2403-4d42-ad88-6adcfe1a5c2b" + "azdata_cell_guid": "2624afc0-2403-4d42-ad88-6adcfe1a5c2b", + "tags": [ + "parameters" + ] }, "outputs": [], "execution_count": null diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/offline-migration/instance-to-VM.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/offline-migration/instance-to-VM.ipynb index d29bebdd9c..871b4ec3d0 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/offline-migration/instance-to-VM.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/offline-migration/instance-to-VM.ipynb @@ -65,7 +65,9 @@ ], "metadata": { "azdata_cell_guid": "76a50416-b804-46ae-a49c-99baaeb31f7d", - "tags": [] + "tags": [ + "parameters" + ] }, "outputs": [], "execution_count": null diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqldb-azCli.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqldb-azCli.ipynb deleted file mode 100644 index b170422434..0000000000 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqldb-azCli.ipynb +++ /dev/null @@ -1,239 +0,0 @@ -{ - "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": [ - "Create Azure SQL Database\r\n", - "==================================\r\n", - "\r\n", - "Description\r\n", - "-----------\r\n", - "This Azure CLI script example creates database in Azure SQL Database and configures a server-level firewall rule. After the script has been successfully run, the database can be accessed from all Azure services and the configured IP address\r\n", - "" - ], - "metadata": { - "azdata_cell_guid": "c9e3ccf4-199a-486d-9e19-7f448bd03f00" - } - }, - { - "cell_type": "markdown", - "source": [ - "Steps of this procedure include:\r\n", - "1. Connect to Azure subscription\r\n", - "1. Provision resource group for SQL Managed Instance\r\n", - "2. Create Sql Server\r\n", - "3. Provision firewall rules to allow access\r\n", - "4. Create Sql Database" - ], - "metadata": { - "azdata_cell_guid": "ac87ba4f-d818-4fb3-8041-ee29ffd17294" - } - }, - { - "cell_type": "markdown", - "source": [ - "#### Sample values for below code block\r\n", - "| Variables | Sample Values |\r\n", - "| ------------ | --------- |\r\n", - "| $Env:BOOTSTRAP_Subscription | Subscription Name or ID |\r\n", - "| $Env:BOOTSTRAP_ResourceGroup | Intended Resource Group Name |\r\n", - "| $location | Valid location from Azure... See appendix at bottom |\r\n", - "| $randomIdentifier | Simple text... For example \"random123\"|\r\n", - "| $server | Name of intended Sql Server in simple text... For example \"server\" |\r\n", - "| $database | Name of intended database in simple text... For example \"database\" |\r\n", - "| $login | Sql Database Login Name... For example \"sampleLogin\" |\r\n", - "| \"password\" | This could be alphanumeric charecters of choice | \r\n", - "| $startIP | Intended Start Ip...For example 165.197.220.224|\r\n", - "| $endIP | Intended End Ip...For example 165.197.220.225 |\r\n", - "" - ], - "metadata": { - "azdata_cell_guid": "a199a24e-220c-4a8b-a090-37e38e725ab3" - } - }, - { - "cell_type": "code", - "source": [ - "$Env:BOOTSTRAP_Subscription = \"\" # Azure Subscription ID/Name for the ADP Resource Group # Both RG are assumed to be in the same subscription\r\n", - "$Env:BOOTSTRAP_ResourceGroup = \"\" # Azure Resource Group which contains the ADP Resources\r\n", - "\r\n", - "# SQL Server \r\n", - "$location =\"\"\r\n", - "$randomIdentifier =\"\"\r\n", - "\r\n", - "$server=\"server-$randomIdentifier\"\r\n", - "$database=\"database-$randomIdentifier\"\r\n", - "\r\n", - "$login=\"\"\r\n", - "$password=\"\"\r\n", - "\r\n", - "$startIP=\"\"\r\n", - "$endIP=\"\"" - ], - "metadata": { - "azdata_cell_guid": "0b2af740-99df-4f44-8cb7-fd00a78f8b9a", - "tags": [] - }, - "outputs": [], - "execution_count": null - }, - { - "cell_type": "markdown", - "source": [ - "## Connect to Azure and Select Subscription\r\n", - "Run the below cell to login to an Azure account. Be sure to check the Windows Taskbar for a subscription selection dialog box.\r\n", - "\r\n", - "_Note: the dialog box window may appear behind the active Azure Data Studio window._" - ], - "metadata": { - "azdata_cell_guid": "acd95a93-f820-48cc-8699-975964225658" - } - }, - { - "cell_type": "code", - "source": [ - "az login\r\n", - "az account set --subscription $Env:BOOTSTRAP_Subscription" - ], - "metadata": { - "azdata_cell_guid": "2a11cdb2-9549-4dab-a2fe-f0fd37474b6d" - }, - "outputs": [], - "execution_count": null - }, - { - "cell_type": "markdown", - "source": [ - "## Create Resource Group\r\n", - "The Data Portability Notebooks provision several resources to enable import and export of Azure SQL DB databases and Azure SQL Managed Instance databases. These resources include Storage, Azure Batch, Azure Function resources and their dependent Azure resources. All resources created by this notebook are associated with a common Azure Resource Group to enable easy management of resources related to Data Portability.\r\n", - "\r\n", - "_Note: this notebook will reuse the Resource Group specified if it already exists._" - ], - "metadata": { - "azdata_cell_guid": "a3a0c72c-04cb-4bb2-8dbc-4d96e7482ce9" - } - }, - { - "cell_type": "code", - "source": [ - "echo \"Creating $resource...\"\r\n", - "az group create --name $Env:BOOTSTRAP_ResourceGroup --location \"$location\"" - ], - "metadata": { - "azdata_cell_guid": "a9272913-cb61-4536-b89a-7826baa7465d" - }, - "outputs": [], - "execution_count": null - }, - { - "cell_type": "markdown", - "source": [ - "## Create Sql Server\r\n", - "To create an Azure SQL Database using the Azure CLI 2.0,create an Azure SQL Server first, which can be done by running the following command" - ], - "metadata": { - "azdata_cell_guid": "70e04ce4-c5ff-4cde-9a21-05fac7275dbf" - } - }, - { - "cell_type": "code", - "source": [ - "echo \"Creating $server in $location...\"\r\n", - "az sql server create --name $server --resource-group $Env:BOOTSTRAP_ResourceGroup --location \"$location\" --admin-user $login --admin-password $password" - ], - "metadata": { - "azdata_cell_guid": "dbd81221-d61e-4441-ad6d-bb4dcef91f0c" - }, - "outputs": [], - "execution_count": null - }, - { - "cell_type": "markdown", - "source": [ - "## Configure Firewall Rule\r\n", - "\r\n", - "" - ], - "metadata": { - "azdata_cell_guid": "22bbc194-c946-493d-ab65-2750246596c3" - } - }, - { - "cell_type": "code", - "source": [ - "echo \"Configuring firewall...\"\r\n", - "az sql server firewall-rule create --resource-group $Env:BOOTSTRAP_ResourceGroup --server $server -n AllowYourIp --start-ip-address $startIP --end-ip-address $endIP" - ], - "metadata": { - "azdata_cell_guid": "7dbbedfd-32cc-467c-b65a-aaf9ece946b7" - }, - "outputs": [], - "execution_count": null - }, - { - "cell_type": "markdown", - "source": [ - "## Create Database on server\r\n", - "" - ], - "metadata": { - "azdata_cell_guid": "b002d01a-6b2d-4b45-bd77-0d139fbe5503" - } - }, - { - "cell_type": "code", - "source": [ - "echo \"Creating $database on $server...\"\r\n", - "az sql db create --resource-group $Env:BOOTSTRAP_ResourceGroup --server $server --name $database --sample-name AdventureWorksLT --edition GeneralPurpose --family Gen5 --capacity 2 --zone-redundant false # zone redundancy is only supported on premium and business critical service tiers" - ], - "metadata": { - "azdata_cell_guid": "dd8d1b41-8ee7-4823-9655-a9d871b9fe97" - }, - "outputs": [], - "execution_count": null - }, - { - "cell_type": "markdown", - "source": [ - "## Appendices\r\n", - "These sections are not vital for the execution of this notebook but provide valuable background information.\r\n", - "\r\n", - "### Appendix: Locations\r\n", - "See the Azure locations page for a complete list of Azure regions along with their general physical location. The following is a list of common North American location settings for this guide:\r\n", - "\r\n", - "#### US Regions\r\n", - "| Setting | Location |\r\n", - "| ------------ | --------- |\r\n", - "| Central US | Iowa |\r\n", - "| East US | Virginia |\r\n", - "| East US 2 | Virginia |\r\n", - "| North Central US | Illinois |\r\n", - "| South Central US | Texas |\r\n", - "| West US 2 | Washington |\r\n", - "| West Central US | Wyoming |\r\n", - "| West US | California | \r\n", - "| Canada Central | Toronto |\r\n", - "| Canada East | Quebec City |\r\n", - "| Brazil South | Sao Paulo |\r\n", - "| Mexico Central | Queretaro |" - ], - "metadata": { - "azdata_cell_guid": "52dd52ff-cabd-40cc-9b34-5a5ebd7ef0c3" - } - } - ] -} \ No newline at end of file diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqldb.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqldb.ipynb index ea1d9b85d5..7520b174ad 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqldb.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqldb.ipynb @@ -2,7 +2,8 @@ "metadata": { "kernelspec": { "name": "powershell", - "display_name": "PowerShell" + "display_name": "PowerShell", + "language": "powershell" }, "language_info": { "name": "powershell", @@ -17,21 +18,63 @@ { "cell_type": "markdown", "source": [ - "Create Azure SQL Database\n", - "==================================\n", + "# Create Azure SQL Database\n", "\n", - "Description\n", - "-----------\n", - "This notebook will help you get created single Azure SQL Database inside Azure SQL Server and configure a server-level firewall rule. For more information see Use PowerShell to create a single database and configure a server-level firewall rule\n", - "" + "## Description\n", + "\n", + "Run this notebook to create a Azure SQL Database in a new Azure SQL Server in the cloud and then configure a server-level firewall rule it. For more information, see [Use PowerShell to create a single database and configure a server-level firewall rule](https://docs.microsoft.com/en-us/azure/azure-sql/database/scripts/create-and-configure-database-powershell).\n", + "\n", + "| Line | Variable | Description | Example |\n", + "| --- | --- | --- | --- |\n", + "| 1 | Subscription | Specify the name or ID of the Azure subscription to create Azure resources in | \"ContosoCorp\\_Infra\" |\n", + "| 2 | ResourceGroup | Choose a name to logically group the Azure resources | \"ContosoBackend\" |\n", + "| 3 | Location | Name of geographic location (See the [Appendices](.\\................\\Program%20Files\\Azure%20Data%20Studio\\resources\\app\\out\\vs\\code\\electron-browser\\Appendices.ipynb) for more information) | \"EastUS2\" |\n", + "| 4 | ServerName | The logical server name has to be unique in the system | \"contoso-srv1\" |\n", + "| 5 | AdminLogin | SQL admin login to create | \"SqlAdmin\" |\n", + "| 6 | Password | Temporary password to use (change in the portal for greater security) | \"Temp123\" |\n", + "| 7 | StartIp | Starting IP to begin the IP firewall rule | \"0.0.0.0\" for everyone |\n", + "| 8 | EndIp | Ending IP to end the IP firewall rule | \"0.0.0.0\" for everyone |\n", + "| 9 | DatabaseName | The sample database name | \"ContosoDb1\" |\n", + "| 10 | DbEdition | Database edition. Allowed values include: _Basic_, _Standard_, _Premium_, _GeneralPurpose_, _BusinessCritical_, _Hyperscale_ | GeneralPurpose |\n", + "| 11 | DbCores | Integer for number of vcores to utilize | 2 |\n", + "| 12 | DbComputeGen | The compute generation component for vcores. Allowed values include: _Gen4_, _Gen5_. | Gen5 |\n", + "| 13 | DbMinCapacity | Minimum capacity of vcores to utilize, integer only | 2 |" ], "metadata": { "azdata_cell_guid": "6af59d69-ade7-480a-b33e-52a86fe5bfd3" } }, + { + "cell_type": "code", + "source": [ + "$Subscription = \"\"\r\n", + "$ResourceGroup = \"\"\r\n", + "$Location = \"\"\r\n", + "$ServerName = \"\"\r\n", + "$AdminLogin = \"\"\r\n", + "$Password = \"\"\r\n", + "$StartIp = \"\"\r\n", + "$EndIp = \"\"\r\n", + "$DatabaseName = \"\"\r\n", + "$DbEdition = \"\"\r\n", + "$DbCores = \"\"\r\n", + "$DbComputeGen = \"\"\r\n", + "$DbMinCapacity= = \"\"" + ], + "metadata": { + "azdata_cell_guid": "c5c06fd6-8e47-4abb-808a-edc8b1c2d690", + "tags": [ + "parameters" + ] + }, + "outputs": [], + "execution_count": null + }, { "cell_type": "markdown", "source": [ + "## Notebook Steps\r\n", + "\r\n", "Steps of this procedure include:\r\n", "1. Connect to Azure subscription\r\n", "1. Provision resource group for SQL Managed Instance\r\n", @@ -43,36 +86,11 @@ "azdata_cell_guid": "d5346c50-c03b-4e3a-983f-7b4b22c78319" } }, - { - "cell_type": "code", - "source": [ - "# Resource Group \r\n", - "$resourceGroupName = \"\" # Name of the resource group to create in the current subscription\r\n", - "$location = \"\" # Name of location (see Appendix for a list of location settings)\r\n", - "\r\n", - "# SQL Server\r\n", - "$serverName = \"mysqlserver-$(Get-Random)\"\r\n", - "$adminLogin = \"\" # Username of Sql server. Default would be 'azureuser'\r\n", - "$password = \"\" # Desired password for Sql Server\r\n", - "\r\n", - "# SQL Database\r\n", - "$databaseName = \"\" # Name of database to be created\r\n", - "\r\n", - "# The ip address range that you want to allow to access your server\r\n", - "$startIp = \"0.0.0.0\"\r\n", - "$endIp = \"0.0.0.0\"" - ], - "metadata": { - "azdata_cell_guid": "c5c06fd6-8e47-4abb-808a-edc8b1c2d690" - }, - "outputs": [], - "execution_count": null - }, { "cell_type": "markdown", "source": [ - "### Connect to Azure \r\n", - "Below command will open a _Dialouge Box_ asking your account credentials." + "### Connect to Azure\r\n", + "Prompt for Azure account credentials in a dialog window outside of ADS." ], "metadata": { "azdata_cell_guid": "e34334a7-0d55-4c18-8c0a-1c4a673629cd" @@ -92,8 +110,8 @@ { "cell_type": "markdown", "source": [ - "### Get Subscription\r\n", - "Below command will open a _Dialouge Box_ with list of subscriptions. Selecting one of those will set that subscription for rest of the commands." + "### Get Subscription\r\n", + "If a subscription is not specified, open a dialog with list of subscriptions. Selecting one will set that subscription for rest of the notebook." ], "metadata": { "azdata_cell_guid": "ed6b781d-ce7e-4b51-a7ec-1eeeb2032c73" @@ -102,8 +120,12 @@ { "cell_type": "code", "source": [ - "$subscription = Get-AzSubscription | Out-GridView -PassThru\r\n", - "Set-AzContext -SubscriptionName $subscription" + "if (!$Subscription)\r\n", + "{\r\n", + " $Subscription = Get-AzSubscription | Out-GridView -PassThru\r\n", + "}\r\n", + "\r\n", + "Set-AzContext -SubscriptionName $Subscription" ], "metadata": { "azdata_cell_guid": "17b57956-98cf-44de-9ab5-348469ddabf4" @@ -114,8 +136,9 @@ { "cell_type": "markdown", "source": [ - "### Create the New Resource Group\r\n", - "_New-AzResourceGroup_ command will create new resource group in given subscription." + "### Resource Group Provisioning\n", + "\n", + "If the specified Azure Resource Group cannot be found, _New-AzResourceGroup_ will create new resource group in the given subscription." ], "metadata": { "azdata_cell_guid": "3ecc2a29-fb77-4f7f-8901-e9c5c71ce1a2" @@ -124,15 +147,17 @@ { "cell_type": "code", "source": [ - "# Create Azure resource group, if necessary\r\n", - "$rg = Get-AzResourceGroup | Where ResourceGroupName -eq $resourceGroupName\r\n", + "$rg = Get-AzResourceGroup | Where ResourceGroupName -eq $ResourceGroup\r\n", "\r\n", "if (!$rg)\r\n", "{\r\n", " # Need to create a new resource group\r\n", - " Write-Output \"Resource Group $resourceGroupName does not exist. Creating...\"\r\n", - " $rg = New-AzResourceGroup -Name $resourceGroupName -Location $location\r\n", - "}" + " Write-Output \"Resource Group $ResourceGroup does not exist. Creating...\"\r\n", + " $rg = New-AzResourceGroup -Name $ResourceGroup -Location $Location\r\n", + "}\r\n", + "\r\n", + "Write-Output \"Using Resource Group:\"\r\n", + "$rg | Format-Table" ], "metadata": { "azdata_cell_guid": "4837690a-2204-49ab-8a19-414a8ce782b6" @@ -143,8 +168,9 @@ { "cell_type": "markdown", "source": [ - "### Create a SQL server with a system wide unique server name\r\n", - "_New-AzSqlServer_ will create Sql Server with required configurations." + "### Create SQL Server\n", + "\n", + "_New-AzSqlServer_ will create an Azure Sql Server instance to logically group databases in." ], "metadata": { "azdata_cell_guid": "2d951526-40dc-49cc-8668-c393eaf58000" @@ -153,12 +179,12 @@ { "cell_type": "code", "source": [ - "Write-Output \"Creating SqlServer with name $serverName ....\"\r\n", - "New-AzSqlServer -ResourceGroupName $resourceGroupName `\r\n", - " -ServerName $serverName `\r\n", - " -Location $location `\r\n", + "Write-Output \"Creating SqlServer with name $ServerName\"\r\n", + "New-AzSqlServer -ResourceGroupName $ResourceGroup `\r\n", + " -ServerName $ServerName `\r\n", + " -Location $Location `\r\n", " -SqlAdministratorCredentials $(New-Object -TypeName System.Management.Automation.PSCredential `\r\n", - " -ArgumentList $adminLogin, $(ConvertTo-SecureString -String $password -AsPlainText -Force))" + " -ArgumentList $AdminLogin, $(ConvertTo-SecureString -String $Password -AsPlainText -Force))" ], "metadata": { "azdata_cell_guid": "c45757ac-6a58-468d-a04c-04504f8a2e0e" @@ -169,8 +195,9 @@ { "cell_type": "markdown", "source": [ - "### Create a server firewall rule that allows access from the specified IP range\r\n", - "_New-AzSqlServerFirewallRule_ creates a new firewall rule for sql server" + "### Create a Server Firewall Rule\n", + "\n", + "_New-AzSqlServerFirewallRule_ creates a new firewall rule for the new SQL Server that allows a range of specified IPs." ], "metadata": { "azdata_cell_guid": "ba895abf-3176-48b5-9e49-a060b3f74370" @@ -179,10 +206,10 @@ { "cell_type": "code", "source": [ - "Write-Output \"Configuring firewall for Sql Server...\"\r\n", - "New-AzSqlServerFirewallRule -ResourceGroupName $resourceGroupName `\r\n", + "Write-Output \"Configuring firewall for Sql Server\"\r\n", + "New-AzSqlServerFirewallRule -ResourceGroupName $ResourceGroup `\r\n", " -ServerName $ServerName `\r\n", - " -FirewallRuleName \"AllowedIPs\" -StartIpAddress $startIp -EndIpAddress $endIp" + " -FirewallRuleName \"AllowedIPs\" -StartIpAddress $StartIp -EndIpAddress $EndIp" ], "metadata": { "azdata_cell_guid": "ceae5670-292f-4c45-9c10-4ac85baf2d07" @@ -193,8 +220,8 @@ { "cell_type": "markdown", "source": [ - "### Create SQL Database\r\n", - "_New-AzSqlDatabase_ command will create new database in the server." + "### Create SQL Database\r\n", + "_New-AzSqlDatabase_ command will create a new database in the server." ], "metadata": { "azdata_cell_guid": "b460ca8f-65a7-4d6c-94b7-6d7dd9655fad" @@ -203,14 +230,13 @@ { "cell_type": "code", "source": [ - "Write-Output \"Creating a gen5 2 vCore database...\"\r\n", - "$database = New-AzSqlDatabase -ResourceGroupName $resourceGroupName `\r\n", + "New-AzSqlDatabase -ResourceGroupName $ResourceGroup `\r\n", " -ServerName $ServerName `\r\n", - " -DatabaseName $databaseName `\r\n", - " -Edition GeneralPurpose `\r\n", - " -VCore 2 `\r\n", - " -ComputeGeneration Gen5 `\r\n", - " -MinimumCapacity 2" + " -DatabaseName $DatabaseName `\r\n", + " -Edition $DbEdition `\r\n", + " -VCore $DbCores `\r\n", + " -ComputeGeneration $DbComputeGen `\r\n", + " -MinimumCapacity $DbMinCapacity" ], "metadata": { "azdata_cell_guid": "dc3b2f6f-83ac-4a4d-9d81-2f534e90913e" @@ -221,7 +247,8 @@ { "cell_type": "markdown", "source": [ - "### Get Database details \r\n", + "### Get Database Details\n", + "\n", "_Get-AzSqlDatabase_ command gets database details on the server specified." ], "metadata": { @@ -231,13 +258,35 @@ { "cell_type": "code", "source": [ - "Get-AzSqlDatabase -ResourceGroupName $resourceGroupName -ServerName $serverName -DatabaseName $databaseName" + "Get-AzSqlDatabase -ResourceGroupName $ResourceGroup -ServerName $ServerName -DatabaseName $DatabaseName" ], "metadata": { "azdata_cell_guid": "5001bf24-5f3f-434e-abf6-a5c21af4aa32" }, "outputs": [], "execution_count": null + }, + { + "cell_type": "markdown", + "source": [ + "## Next Steps\r\n", + "\r\n", + "### Update SQL Server Password\r\n", + "Do not forget to open the Azure portal to the specified Resource Group in an external browser and change the new server's password. It is not recommended to keep the database password used in this notebook because it stores results as plain text. \r\n", + "\r\n", + "### More Automation\r\n", + "Use ADS Notebooks to write custom scripts for:\r\n", + "* Commonly used Extract, Transform, Load operations\r\n", + "* Data migration and validation\r\n", + "* Storage backup\r\n", + "* Data integration\r\n", + "\r\n", + "### Related Notebooks\r\n", + "For existing database owners, Migrate a database to Azure SQLDB using this notebook. " + ], + "metadata": { + "azdata_cell_guid": "d8b88393-baba-428d-b136-7125be6d5630" + } } ] } \ No newline at end of file diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqlmi.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqlmi.ipynb index 80445115a0..b67012a02a 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqlmi.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqlmi.ipynb @@ -2,7 +2,8 @@ "metadata": { "kernelspec": { "name": "powershell", - "display_name": "PowerShell" + "display_name": "PowerShell", + "language": "powershell" }, "language_info": { "name": "powershell", @@ -76,7 +77,10 @@ "" ], "metadata": { - "azdata_cell_guid": "e574921c-3611-47d7-a872-564d07030815" + "azdata_cell_guid": "e574921c-3611-47d7-a872-564d07030815", + "tags": [ + "parameters" + ] }, "outputs": [], "execution_count": null diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqlvm-azCli.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqlvm-azCli.ipynb deleted file mode 100644 index 6bffb40612..0000000000 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqlvm-azCli.ipynb +++ /dev/null @@ -1,557 +0,0 @@ -{ - "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": [ - "# Create Azure Sql Virtual Machine using Az-Cli" - ], - "metadata": { - "azdata_cell_guid": "420658c9-5177-4220-9b7e-34429d2e526d" - } - }, - { - "cell_type": "markdown", - "source": [ - "## PS Version and Modules\r\n", - "This notebook uses a PowerShell Notebook kernel (YouTube video) and requires PS v5.1 or greater. It also uses the latest version of Azure CLI. To install, see https://aka.ms/installazurecliwindows. Update instructions can be found at https://aka.ms/doc/UpdateAzureCliMsi" - ], - "metadata": { - "azdata_cell_guid": "e0d6402d-4f1c-4e37-923e-1e9483431587" - } - }, - { - "cell_type": "code", - "source": [ - "# Check that PowerShell >= v5.1 and Azure Command Line Interface (Az CLI) are installed\r\n", - "if ($PSVersionTable.PSVersion.Major -lt 5)\r\n", - "{\r\n", - " Write-Warning \"Please install latest version of PowerShell. Do not continue executing the rest of the notebook.\"\r\n", - "}\r\n", - "else {\r\n", - " $psVersion = $PSVersionTable.PSVersion.ToString()\r\n", - " Write-Output \"Found PS version... $psVersion\"\r\n", - " # Check for Azure CLI\r\n", - " $azCli = (&az --version) \r\n", - " if ($azCli) { \r\n", - " $azVersion = $azCli[0].Split()[-1]\r\n", - " Write-Output \"Found Az CLI version... $azVersion\"\r\n", - " }\r\n", - "}" - ], - "metadata": { - "azdata_cell_guid": "5a6893cf-e29d-4855-8771-0101bb6e55cd", - "tags": [ - "hide_input" - ] - }, - "outputs": [], - "execution_count": null - }, - { - "cell_type": "markdown", - "source": [ - "## Set Variables for the Notebook" - ], - "metadata": { - "azdata_cell_guid": "8998da5f-e4aa-4b32-aadf-51077748c56d" - } - }, - { - "cell_type": "code", - "source": [ - "# ADP Resource \r\n", - "$Env:BOOTSTRAP_Subscription = \"\" # Azure Subscription ID/Name # The bacpac files and ADP Resources are assumed to be in the same subscription\r\n", - "$Env:BOOTSTRAP_ResourceGroup = \"TestResourceGroup\" # Azure Resource Group which contains the ADP Resources\r\n", - "\r\n", - "# SQL Server \r\n", - "$VMName = \"TestVM\" # Name of the Virtual Machine to be created\r\n", - "$ImageSku = \"Enterprise\" # Choose your Image sku (see appendix)\r\n", - "$Location = \"East US\" # see Appendix for a list of location settings\r\n", - "$VmUsername = \"\" # Username of Virtual Machine to be created\r\n", - "$VmPassword = \"\" # Password of Virtual Machine to be created\r\n", - "\r\n", - "# Set Variables for ADP Resources\r\n", - "$Env:BOOTSTRAP_FUNC = $Env:BOOTSTRAP_ResourceGroup + \"Control\" \r\n", - "$Env:BOOTSTRAP_BATCH = $Env:BOOTSTRAP_ResourceGroup.ToLower() + \"batch\"\r\n", - "$Env:BOOTSTRAP_VNET = $Env:BOOTSTRAP_ResourceGroup + \"Vnet\"" - ], - "metadata": { - "azdata_cell_guid": "a6f7e1bb-6517-4c43-a63b-d70a5e8627ba", - "tags": [ - "hide_input" - ] - }, - "outputs": [], - "execution_count": null - }, - { - "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": "c0f151bc-d1a3-4d41-8c93-b67f7a068be0" - } - }, - { - "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($Env:BOOTSTRAP_Subscription)) #If there is a subscription specified by user in the variables section\r\n", - " {\r\n", - " $specified_Subscription= az account show --subscription $Env:BOOTSTRAP_Subscription -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", - " $Env:BOOTSTRAP_Subscription = $subscription \r\n", - " Write-Output \"Using subscription... '$Env:BOOTSTRAP_Subscription' ... '$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", - "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-InputForImportFunction\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]$BackupFiles_StorageAccount,\r\n", - " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$BackupFiles_ContainerName,\r\n", - " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$VNetName, \r\n", - " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$TargetRGName,\r\n", - " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$SqlServerName,\r\n", - " [Parameter (Mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$SqlServerPassword\r\n", - " )\r\n", - " \r\n", - " $Result = @{}\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", - " $Result['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 + '/Import'\r\n", - " $Result['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\r\n", - "\r\n", - " ## Create access token to source sql server\r\n", - " $targetAccessToken = az account get-access-token --resource=https://database.windows.net --query accessToken\r\n", - " $targetAccessToken\r\n", - "\r\n", - " ## Build JSon object for Body\r\n", - " $Body = @{\r\n", - " batchAccountUrl = $BatchAccountURL\r\n", - " VNetSubnetId= $VNetSubNetID\r\n", - " storageAccountName = $BackupFiles_StorageAccount\r\n", - " containerName = $BackupFiles_ContainerName\r\n", - " targetSqlServerResourceGroupName = $TargetRGName\r\n", - " targetSqlServerName = $SQLServerName \r\n", - " userName = $SqlServerLogin \r\n", - " targetAccessToken = $targetAccessToken\r\n", - " sqlAdminPassword = $SqlServerPassword\r\n", - " }\r\n", - " $json = $Body | ConvertTo-Json\r\n", - " $Result['Body']=$json\r\n", - "\r\n", - " $Result\r\n", - " \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": "ea9ddf9c-4c09-4db3-94ea-e01bc5f105c9", - "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": "2a5a155f-556d-451d-a0d4-b802017946df" - } - }, - { - "cell_type": "code", - "source": [ - "Login-Azure" - ], - "metadata": { - "azdata_cell_guid": "77067078-7ec5-4d07-803b-5c52dfcf06f0", - "tags": [ - "hide_input" - ] - }, - "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": "717960de-4baf-4b78-bcec-3a8e386b42b7" - } - }, - { - "cell_type": "code", - "source": [ - "Verify-ADPResources -Subscription $Env:BOOTSTRAP_Subscription -ADPResourceGroupName $Env:BOOTSTRAP_ResourceGroup `\r\n", - " -BatchAccountName $Env:BOOTSTRAP_BATCH -FunctionName $Env:BOOTSTRAP_FUNC -VNetName $Env:BOOTSTRAP_VNET " - ], - "metadata": { - "azdata_cell_guid": "22e8a9ed-d2e0-46eb-92b0-8c1108b60b67", - "tags": [ - "hide_input" - ] - }, - "outputs": [], - "execution_count": null - }, - { - "cell_type": "markdown", - "source": [ - "## Create a resource group\r\n", - "\r\n", - "In Azure, all resources are allocated in a resource management group. Resource groups provide logical groupings of resources that make them easier to work with as a collection" - ], - "metadata": { - "azdata_cell_guid": "73e7c7f9-f518-4b0a-87d1-d43c6a10cbad" - } - }, - { - "cell_type": "code", - "source": [ - "$rsgExists = az group exists -n $Env:BOOTSTRAP_ResourceGroup\r\n", - "if ($rsgExists -eq 'false') {\r\n", - " az group create -l $Location -n $Env:BOOTSTRAP_ResourceGroup\r\n", - "}" - ], - "metadata": { - "azdata_cell_guid": "7e95158c-9ddc-4b5e-b289-2086a2d03c15", - "tags": [ - "hide_input" - ] - }, - "outputs": [], - "execution_count": null - }, - { - "cell_type": "markdown", - "source": [ - "## Create a virtual machine\r\n", - "\r\n", - "" - ], - "metadata": { - "azdata_cell_guid": "222d6b8d-9789-4416-b512-63b1ce6f11e0" - } - }, - { - "cell_type": "code", - "source": [ - "az vm create -n sql -g $Env:BOOTSTRAP_ResourceGroup --image MicrosoftSQLServer:SQL2017-WS2016:Standard:14.0.1000200 --location $Location --admin-username $VmUsername --admin-password $VmPassword --verbose" - ], - "metadata": { - "azdata_cell_guid": "37ab908d-839a-45e9-89cf-78ed2452debe", - "tags": [ - "hide_input" - ] - }, - "outputs": [], - "execution_count": null - }, - { - "cell_type": "markdown", - "source": [ - "## Get VM information with queries\r\n", - "Now that a VM has been created, detailed information about it can be retrieved. The common command for getting information from a resource is _show_" - ], - "metadata": { - "azdata_cell_guid": "9de4dd69-c9e3-4e10-89f1-cc785ea712b4" - } - }, - { - "cell_type": "code", - "source": [ - "az vm show --name TutorialVM1 --resource-group TutorialResources" - ], - "metadata": { - "azdata_cell_guid": "51a4a092-1697-476c-934f-75a1a30dab7f", - "tags": [ - "hide_input" - ] - }, - "outputs": [], - "execution_count": null - }, - { - "cell_type": "markdown", - "source": [ - "Lot of information can be seen, which can be difficult to parse visually. The returned JSON contains information on authentication, network interfaces, storage, and more. Most importantly, it contains the Azure object IDs for resources that the VM is connected to. Object IDs allow accessing these resources directly to get more information about the VM's configuration and capabilities.\r\n", - "\r\n", - "In order to extract the object ID , the --query argument is used. Queries are written in the JMESPath query language. Start with getting the network interface controller (NIC) object ID" - ], - "metadata": { - "azdata_cell_guid": "902e834e-bbbf-40f4-80db-48d3b4b90f99" - } - }, - { - "cell_type": "code", - "source": [ - "az vm show --name TutorialVM1 \\\r\n", - " --resource-group TutorialResources \\\r\n", - " --query 'networkProfile.networkInterfaces[].id' \\\r\n", - " --output tsv" - ], - "metadata": { - "azdata_cell_guid": "2bc8e0c7-d936-42ce-9e6a-e66207cd78f0", - "tags": [ - "hide_input" - ] - }, - "outputs": [], - "execution_count": null - }, - { - "cell_type": "markdown", - "source": [ - "### Appendix: Locations\r\n", - "See the Azure locations page for a complete list of Azure regions along with their general physical location. The following is a list of common North American location settings for this guide:\r\n", - "\r\n", - "#### US Regions\r\n", - "| Setting | Location |\r\n", - "| ------------ | --------- |\r\n", - "| Central US | Iowa |\r\n", - "| East US | Virginia |\r\n", - "| East US 2 | Virginia |\r\n", - "| North Central US | Illinois |\r\n", - "| South Central US | Texas |\r\n", - "| West US 2 | Washington |\r\n", - "| West Central US | Wyoming |\r\n", - "| West US | California | \r\n", - "| Canada Central | Toronto |\r\n", - "| Canada East | Quebec City |\r\n", - "| Brazil South | Sao Paulo |\r\n", - "| Mexico Central | Queretaro |\r\n", - "\r\n", - "### Appendix: Storage Skus\r\n", - "Use these as values for provisioning storage skus. \r\n", - "\r\n", - "Data for table taken from SKU Types page but is subject to change. Not all skus are listed here. SKU type names are case-sensitive.\r\n", - "\r\n", - "| Name |\r\n", - "| -----|\r\n", - "| Developer |\r\n", - "| Enterprise |\r\n", - "| Express |\r\n", - "| Standard |\r\n", - "| Web |" - ], - "metadata": { - "azdata_cell_guid": "a40b46e4-4b92-4ada-b022-4342ce1b35f2" - } - } - ] -} \ No newline at end of file diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqlvm.ipynb b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqlvm.ipynb index 5aa7a09543..b1dce3fe0c 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqlvm.ipynb +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/provisioning/create-sqlvm.ipynb @@ -70,7 +70,9 @@ ], "metadata": { "azdata_cell_guid": "b9aff9cc-a3af-41cb-a2a5-35f36b2bcc55", - "tags": [] + "tags": [ + "parameters" + ] }, "outputs": [], "execution_count": null diff --git a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/readme.md b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/readme.md index cdf796fda8..748e4c268a 100644 --- a/extensions/azurehybridtoolkit/notebooks/hybridbook/content/readme.md +++ b/extensions/azurehybridtoolkit/notebooks/hybridbook/content/readme.md @@ -1,9 +1,12 @@ -# Welcome to the Azure SQL Hybrid Cloud Toolkit! +# Welcome to the Azure SQL Hybrid Toolkit + +## About + +The **Azure SQL Hybrid Toolkit** is a [Jupyter Book](https://jupyterbook.org/intro.html) extension of [Azure Data Studio](https://docs.microsoft.com/en-us/sql/azure-data-studio/download-azure-data-studio) (ADS) designed to help [Azure SQL Database](https://azure.microsoft.com/en-us/services/sql-database/) and ADS users deploy, migrate and configure for a hybrid cloud environment. The toolkit was designed with and intended to be executed within ADS. This is to ensure the best possible user experience for those without vast knowledge of Azure services while adhering closely to the software _best practices_ standards required by experienced cloud users. + ## Chapters * [Prerequisites and Initial Setup](prereqs.ipynb) - Notebook installation of required modules. -* [ADP](ADP/readme.md) - manage ADP Orchestrator import/export requests onto an SQL Server. - * [Assessments](Assessments/readme.md) - Notebooks that contain examples to determine whether a given database or SQL Server instance is ready to migrate by utilizing SQL Assessments. SQL instances are scanned based on a "best practices" set of rules. * [Networking](networking/readme.md) - Setup secure Point-to-Site (P2S) or Site-to-Site (S2S) network connectivity to Microsoft Azure using a Virtual Private Network (VPN). This notebook serves as a building block for other notebooks as communicating securely between on-premise and Azure is essential for many tasks. @@ -18,11 +21,7 @@ * [Glossary](glossary.md) - set of defined terms. -* [Appendices](appendices.md) - misc info. - -## About - -The **Azure SQL Hybrid Cloud Toolkit** is a [Jupyter Book](https://jupyterbook.org/intro.html) extension of [Azure Data Studio](https://docs.microsoft.com/en-us/sql/azure-data-studio/download-azure-data-studio) (ADS) designed to help [Azure SQL Database](https://azure.microsoft.com/en-us/services/sql-database/) and ADS users deploy, migrate and configure for a hybrid cloud environment. The toolkit was designed with and intended to be executed within ADS. This is to ensure the best possible user experience for those without vast knowledge of Azure services while adhering closely to the software _best practices_ standards required by experienced cloud users. +* [Appendices](Appendices.ipynb) - misc info. ## Goals and Methodology The toolkit better positions a customer with regards to planning, migrating, and thriving in a hybrid cloud environment by: @@ -35,3 +34,12 @@ The toolkit better positions a customer with regards to planning, migrating, and * By design, Notebooks are written to be executed from top-to-bottom. Therefore, each notebook has a specific task to perform and should focus only on that task. It may contain several cells to execute but it will adhere to the one-task per notebook paradigm **NOTE:** Executing notebooks could potentially create new Azure Resources which may incur charges to the Azure Subscription. Make sure the repercussions of executing any cells are understood. + +## General Guidelines +1. Read notebooks carefully to understand their use +2. Execute the Prerequisites and Initial Setup notebook once per setup +3. Configure individual notebooks by modifying the cells tagged as "Parameters" +4. Execute notebook from top-to-bottom to complete a task +5. Save the executed notebook as a different notebook, if desired + +The resulting output is displayed as text underneath each cell when executed. The notebook can be shared or archived easily. Furthermore, the toolkit's tasks are building blocks for a more advanced automation framework. Hopefully, this toolkit will enable greater understanding for the Azure SQL Hybrid user, especially when it comes to automation. \ No newline at end of file