{"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"," * Capacity settings from the P SKU are transferred to the F SKU\n"," * Capacity settings\n"," * Notification settings\n"," * Access settings\n"," * Disaster recovery settings\n"," * Spark settings\n"," * Delegated tenant settings\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","key_vault_uri = '' # Enter your Azure Key Vault URI\n","key_vault_tenant_id = '' # Enter the name of the Azure Key Vault secret which stores your Tenant ID\n","key_vault_client_id = '' # Enter the name of the Azure Key Vault secret which stores your Client ID (Application ID)\n","key_vault_client_secret = '' # Enter the name of the Azure Key Vault secret which stores your Client Secret\n","resource_group = '' # Enter the name of the resource group (to be used to create the new F skus)"]},{"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":["labs.migrate_capacities(\n"," azure_subscription_id = azure_subscription_id,\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"," 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":["labs.migrate_capacities(\n"," azure_subscription_id = azure_subscription_id,\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"," 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":["labs.migrate_capacities(\n"," azure_subscription_id = azure_subscription_id,\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"," 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","labs.migrate_capacities(\n"," azure_subscription_id = azure_subscription_id,\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"," 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",")\n","\n","# Optionally migrate settings\n","\"\"\"\n","labs.migrate_capacity_settings(\n"," source_capacity=source_capacity, \n"," target_capacity=target_capacity\n",")\n","labs.migrate_access_settings(\n"," source_capacity=source_capacity, \n"," target_capacity=target_capacity\n",")\n","labs.migrate_delegated_tenant_settings(\n"," source_capacity=source_capacity, \n"," target_capacity=target_capacity\n",")\n","labs.migrate_disaster_recovery_settings(\n"," source_capacity=source_capacity, \n"," target_capacity=target_capacity\n",")\n","labs.migrate_notification_settings(\n"," source_capacity=source_capacity, \n"," target_capacity=target_capacity\n",")\n","labs.migrate_spark_settings(\n"," source_capacity=source_capacity, \n"," target_capacity=target_capacity\n",")\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"," )\n"," # Optionally migrate settings\n"," \"\"\"\n"," labs.migrate_capacity_settings(\n"," source_capacity=source_capacity, \n"," target_capacity=target_capacity\n"," )\n"," labs.migrate_access_settings(\n"," source_capacity=source_capacity, \n"," target_capacity=target_capacity\n"," )\n"," labs.migrate_delegated_tenant_settings(\n"," source_capacity=source_capacity, \n"," target_capacity=target_capacity\n"," )\n"," labs.migrate_disaster_recovery_settings(\n"," source_capacity=source_capacity, \n"," target_capacity=target_capacity\n"," )\n"," labs.migrate_notification_settings(\n"," source_capacity=source_capacity, \n"," target_capacity=target_capacity\n"," )\n"," labs.migrate_spark_settings(\n"," source_capacity=source_capacity, \n"," target_capacity=target_capacity\n"," )\n"," \"\"\"\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":["labs.migrate_fabric_trial_capacity(\n"," azure_subscription_id = azure_subscription_id,\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"," 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}