{ "cells": [ { "cell_type": "markdown", "id": "5c27dfd1-4fe0-4a97-92e6-ddf78889aa93", "metadata": { "nteract": { "transient": { "deleting": false } } }, "source": [ "### Install the latest .whl package\n", "\n", "Check [here](https://pypi.org/project/semantic-link-labs/) to see the latest version." ] }, { "cell_type": "code", "execution_count": null, "id": "d5cae9db-cef9-48a8-a351-9c5fcc99645c", "metadata": { "jupyter": { "outputs_hidden": true, "source_hidden": false }, "nteract": { "transient": { "deleting": false } } }, "outputs": [], "source": [ "%pip install semantic-link-labs" ] }, { "cell_type": "markdown", "id": "2856d26d", "metadata": {}, "source": [ "### Requirements\n", "* Must have an Azure Subscription\n", "* Must [register an App](https://ms.portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade)\n", " * Permissions: Will need the Contributor role at the scope where the resources will be created, which is often the subscription level\n", "* Azure Key Vault\n", " * [Set up](https://learn.microsoft.com/azure/key-vault/secrets/quick-create-portal) within the Azure Subscription\n", " * Save secrets for the Tenant ID, Client ID (Application ID), Client Secret\n", " * Permissions: Ensure the user who will be executing the notebooks has “Key Vault Secrets User”\n", "* Fabric Permissions\n", " * User should be a tenant admin. This ensures they have the necessary authority to execute and manage the notebooks without encountering permission issues.\n", "\n", "### Result\n", "* F skus are created for each (specified) capacity\n", " * Within the same region as the P SKU\n", " * Equivalent SKU size as the P SKU\n", " * Same admins as listed on the P SKU\n", " * All workspaces are migrated to the corresponding new capacity\n", "* The names of the newly created F SKU capacities will be an alphanumeric lowercase version of the P SKU capacity name, suffixed with 'fsku'. As an example: \"My capacity_3!\" -> \"mycapacity3fsku\"." ] }, { "cell_type": "markdown", "id": "b195eae8", "metadata": {}, "source": [ "### Import the library and set the initial parameters" ] }, { "cell_type": "code", "execution_count": null, "id": "1344e286", "metadata": {}, "outputs": [], "source": [ "import sempy_labs as labs\n", "import sempy_labs.admin as admin\n", "\n", "azure_subscription_id = '' # Enter your Azure subscription ID\n", "resource_group = '' # Enter the name of the resource group (to be used to create the new F skus)\n", "\n", "key_vault_uri = '', # Enter your key vault URI\n", "key_vault_tenant_id = '', # Enter the key vault key to the secret storing your Tenant ID\n", "key_vault_client_id = '', # Enter the key vault key to the secret storing your Client ID (Application ID)\n", "key_vault_client_secret = '' # Enter the key vault key to the secret storing your Client Secret" ] }, { "cell_type": "markdown", "id": "5a3fe6e8-b8aa-4447-812b-7931831e07fe", "metadata": { "nteract": { "transient": { "deleting": false } } }, "source": [ "### Migrate a single P SKU -> F SKU\n", "Set the 'capacities' parameter to the single P SKU." ] }, { "cell_type": "code", "execution_count": null, "id": "3655dd88", "metadata": {}, "outputs": [], "source": [ "with labs.service_principal_authentication(\n", " key_vault_uri=key_vault_uri, \n", " key_vault_tenant_id=key_vault_tenant_id,\n", " key_vault_client_id=key_vault_client_id,\n", " key_vault_client_secret=key_vault_client_secret):\n", "\n", " labs.migrate_capacities(\n", " azure_subscription_id = azure_subscription_id,\n", " resource_group = resource_group,\n", " capacities = 'CapacityA',\n", " p_sku_only = True,\n", " )" ] }, { "cell_type": "markdown", "id": "175a59b8", "metadata": {}, "source": [ "### Migrate a list of P SKUs to F SKUs\n", "Set the 'capacities' parameter to a list of P SKUs." ] }, { "cell_type": "code", "execution_count": null, "id": "3a7a80ec", "metadata": {}, "outputs": [], "source": [ "with labs.service_principal_authentication(\n", " key_vault_uri=key_vault_uri, \n", " key_vault_tenant_id=key_vault_tenant_id,\n", " key_vault_client_id=key_vault_client_id,\n", " key_vault_client_secret=key_vault_client_secret):\n", "\n", " labs.migrate_capacities(\n", " azure_subscription_id = azure_subscription_id,\n", " resource_group = resource_group,\n", " capacities = ['CapacityA', 'CapacityB', 'CapacityC'],\n", " p_sku_only = True,\n", " )" ] }, { "cell_type": "markdown", "id": "30438799", "metadata": {}, "source": [ "### Migrate all P SKUs to F SKUs\n", "Set the 'capacities' parameter to None." ] }, { "cell_type": "code", "execution_count": null, "id": "315c2dc7", "metadata": {}, "outputs": [], "source": [ "with labs.service_principal_authentication(\n", " key_vault_uri=key_vault_uri, \n", " key_vault_tenant_id=key_vault_tenant_id,\n", " key_vault_client_id=key_vault_client_id,\n", " key_vault_client_secret=key_vault_client_secret):\n", "\n", " labs.migrate_capacities(\n", " azure_subscription_id = azure_subscription_id,\n", " resource_group = resource_group,\n", " capacities = None,\n", " p_sku_only = True,\n", " )" ] }, { "cell_type": "markdown", "id": "1d8e73b2", "metadata": {}, "source": [ "### Migrate a list of P SKUs to F SKUs; associate each capacity with a specific resource group\n", "This process ensures that each F SKU is created within the resource group specified in the resource_group_mapping dictionary." ] }, { "cell_type": "code", "execution_count": null, "id": "2854bf8a", "metadata": {}, "outputs": [], "source": [ "resource_group_mapping = {\n", " \"CapacityA\": \"ResourceGroupA\",\n", " \"CapacityB\": \"ResourceGroupA\",\n", " \"CapacityC\": \"ResourceGroupB\",\n", "}\n", "\n", "with labs.service_principal_authentication(\n", " key_vault_uri=key_vault_uri, \n", " key_vault_tenant_id=key_vault_tenant_id,\n", " key_vault_client_id=key_vault_client_id,\n", " key_vault_client_secret=key_vault_client_secret):\n", "\n", " labs.migrate_capacities(\n", " azure_subscription_id = azure_subscription_id,\n", " resource_group = resource_group_mapping,\n", " capacities = ['CapacityA', 'CapacityB', 'CapacityC'],\n", " p_sku_only = True,\n", " )" ] }, { "cell_type": "markdown", "id": "c3f497c8", "metadata": {}, "source": [ "### Migrate a single source capacity to a target capacity (target capacity already created)" ] }, { "cell_type": "code", "execution_count": null, "id": "a4f0b5a2", "metadata": {}, "outputs": [], "source": [ "source_capacity = '' # Enter the Source capacity name\n", "target_capacity = '' # Enter the Target capacity name (already exists) \n", "\n", "admin.assign_workspaces_to_capacity(\n", " source_capacity=source_capacity,\n", " target_capacity=target_capacity,\n", " workspace=None,\n", ")" ] }, { "cell_type": "markdown", "id": "e0db744b", "metadata": {}, "source": [ "### Migrate a list of source capacities to target capacities (target capacity already created)" ] }, { "cell_type": "code", "execution_count": null, "id": "0e04d519", "metadata": {}, "outputs": [], "source": [ "capacity_mapping = {\n", " \"capacitya\": \"capacityanew\", # Format is \"Source SKU\": \"Target SKU\"\n", " \"capacityb\": \"capacitybnew\",\n", " \"capacityc\": \"capacitycnew\",\n", "}\n", "\n", "capacities = list(capacity_mapping.keys())\n", "\n", "for capacity in capacities:\n", " admin.assign_workspaces_to_capacity(\n", " source_capacity=capacity,\n", " target_capacity=capacity_mapping.get(capacity),\n", " workspace=None,\n", " )" ] }, { "cell_type": "markdown", "id": "67787c3a", "metadata": {}, "source": [ "### Migrate a Fabric Trial Capacity (FT1) to a Fabric Capacity (F SKU)" ] }, { "cell_type": "code", "execution_count": null, "id": "4efb55b2", "metadata": {}, "outputs": [], "source": [ "with labs.service_principal_authentication(\n", " key_vault_uri=key_vault_uri, \n", " key_vault_tenant_id=key_vault_tenant_id,\n", " key_vault_client_id=key_vault_client_id,\n", " key_vault_client_secret=key_vault_client_secret):\n", "\n", " labs.migrate_fabric_trial_capacity(\n", " azure_subscription_id = azure_subscription_id,\n", " resource_group = resource_group,\n", " source_capacity = '', # The name of the Trial capacity.\n", " target_capacity = '', # The name of Fabric capacity (if it does not exist it will be created).\n", " target_capacity_sku = \"F64\", # Defaults to F64 but can specify the required SKU.\n", " target_capacity_admin_members = None, # Setting this to None will use the same admin members as the Trial capacity.\n", " )" ] } ], "metadata": { "kernel_info": { "name": "synapse_pyspark" }, "kernelspec": { "display_name": "Synapse PySpark", "language": "Python", "name": "synapse_pyspark" }, "language_info": { "name": "python" }, "microsoft": { "language": "python" }, "nteract": { "version": "nteract-front-end@1.0.0" }, "spark_compute": { "compute_id": "/trident/default" }, "synapse_widget": { "state": {}, "version": "0.1" }, "widgets": {} }, "nbformat": 4, "nbformat_minor": 5 }