hdinsight-migration

作者: microsoft

更新檢查 — 每次工作階段一次(強制) 此技能在會話中首次使用時,請先執行檢查更新技能再繼續。

npx skills add https://github.com/microsoft/skills-for-fabric --skill hdinsight-migration

Update Check — ONCE PER SESSION (mandatory) The first time this skill is used in a session, run the check-updates skill before proceeding.

  • GitHub Copilot CLI / VS Code: invoke the check-updates skill.
  • Claude Code / Cowork / Cursor / Windsurf / Codex: compare local vs remote package.json version.
  • Skip if the check was already performed earlier in this session.

CRITICAL NOTES

  1. To find workspace details (including its ID) from a workspace name: list all workspaces, then use JMESPath filtering
  2. To find item details (including its ID) from workspace ID, item type, and item name: list all items of that type in that workspace, then use JMESPath filtering
  3. HDInsight has no mssparkutils or dbutils equivalent — notebookutils is net-new capability being introduced
  4. HiveContext and SQLContext are legacy Spark 1.x/2.x APIs — Fabric uses Spark 3.x SparkSession exclusively
  5. wasb:// paths are deprecated and require a Storage Account key or SAS — replace with OneLake shortcuts

HDInsight → Microsoft Fabric Migration

Prerequisite Knowledge

Read these companion documents before executing migration tasks:

  • COMMON-CORE.md — Fabric REST API patterns, authentication, token audiences, item discovery
  • COMMON-CLI.mdaz rest, az login, token acquisition, Fabric REST via CLI
  • SPARK-AUTHORING-CORE.md — Notebook deployment, lakehouse creation, Spark job execution

For notebook and Lakehouse creation, see spark-authoring-cli. For Fabric Warehouse DDL/DML authoring, see sqldw-authoring-cli.


Table of Contents

TopicReference
Migration Workload Map§ Migration Workload Map
SparkSession & Context API Changes§ SparkSession API Changes
WASB / ABFS → OneLake Path Migrationpath-migration.md
Hive DDL → Delta Lake / Lakehouse Schemashive-to-delta.md
Oozie → Fabric Pipelines§ Oozie → Fabric Pipelines
Introducing notebookutils§ Introducing notebookutils
Before/After Code Patternscode-patterns.md
Spark Configuration Differences§ Spark Configuration Differences
Must / Prefer / Avoid§ Must / Prefer / Avoid
Authentication & Token AcquisitionCOMMON-CORE.md § Authentication
Lakehouse ManagementSPARK-AUTHORING-CORE.md § Lakehouse Management

Migration Workload Map

HDInsight ComponentFabric TargetNotes
Spark cluster (notebooks, scripts)Fabric Spark (Lakehouse / Notebooks / SJD)No persistent cluster — Starter Pool or Custom Pool provides on-demand Spark
Hive / HiveServer2Lakehouse SQL Endpoint + Lakehouse schemasDelta Lake replaces Hive metastore; schemas provide namespace equivalent
HBaseFabric Warehouse or Azure Cosmos DB (separate from Fabric)HBase has no direct Fabric equivalent — assess workload access patterns
Oozie workflowsFabric Data PipelinesMap Oozie actions to Fabric activities; see § Oozie → Fabric Pipelines
YARN Resource ManagerFabric Spark monitoring (Spark UI, Monitoring Hub)No YARN — Fabric manages compute automatically
AmbariFabric Monitoring Hub + Admin PortalCluster health, capacity, and job monitoring
WASB / ABFS storageOneLake Shortcutsabfss://[email protected]/See path-migration.md
Ranger policiesFabric workspace roles + OneLake data access rolesMap Ranger row/column filters to Lakehouse row-level security
Livy REST serverFabric Livy APICompatible endpoint — see SPARK-AUTHORING-CORE.md

SparkSession & Context API Changes

HDInsight Spark clusters often use legacy Spark 1.x / 2.x API styles. Replace all of these with the unified SparkSession:

Legacy HDInsight PatternFabric Spark 3.x Replacement
from pyspark import SparkContext; sc = SparkContext()Not needed — sc = spark.sparkContext (pre-instantiated)
from pyspark.sql import HiveContext; hc = HiveContext(sc)Not needed — spark session has Hive-compatible SQL support via Delta schemas
from pyspark.sql import SQLContext; sqlc = SQLContext(sc)Not needed — use spark.sql(...) directly
SparkSession.builder.enableHiveSupport().getOrCreate()Not needed in Fabric — spark is pre-built and available
sc.textFile("wasb://[email protected]/path")spark.read.text("abfss://[email protected]/lh.Lakehouse/Files/path")
sqlContext.sql("CREATE TABLE ... STORED AS ORC")See hive-to-delta.md for Delta DDL equivalent

In Fabric notebooks, spark (SparkSession) and sc (SparkContext) are pre-instantiated — do not call SparkContext() or SparkSession.builder...getOrCreate() at the top of migrated notebooks.


Oozie → Fabric Pipelines

Map Oozie workflow actions to Fabric Data Pipeline activities:

Oozie Action TypeFabric Pipeline ActivityNotes
<spark> actionNotebook activity or Spark Job Definition activityPass parameters via notebook cell parameters or SJD arguments
<hive> actionScript activity (SQL) against Lakehouse SQL EndpointConvert HiveQL to Spark SQL or Delta SQL
<shell> actionAzure Function activity or Web activityShell scripts must be refactored; no direct shell execution in Fabric Pipelines
<java> actionAzure Batch activity (external) or refactor to PySparkJava MapReduce jobs must be rewritten
<sqoop> actionCopy Data activity (Fabric Data Factory connector)Sqoop import/export maps to Fabric Copy Data with JDBC source/sink
<coordinator> (time-based schedule)Pipeline schedule triggerSet recurrence in pipeline trigger; supports cron-like expressions
<coordinator> (data-triggered)Storage Event triggerTrigger on OneLake file arrival

Delegate to spark-authoring-cli for notebook and SJD creation after mapping pipeline activities.


Introducing notebookutils

HDInsight Spark had no built-in utility framework equivalent to mssparkutils or dbutils. When migrating to Fabric, introduce notebookutils for common operations:

OperationOld HDInsight Approachnotebookutils Equivalent
List filesdbutils (N/A) / HDFS CLInotebookutils.fs.ls("abfss://...")
Copy fileHDFS API / shutilnotebookutils.fs.cp(src, dest)
Read secretAzure Key Vault REST callnotebookutils.credentials.getSecret(keyVaultUrl, secretName)
Get notebook contextNot availablenotebookutils.runtime.context — returns workspace ID, notebook ID, etc.
Run child notebookNot availablenotebookutils.notebook.run("notebook_name", timeout, {"param": "value"})
Exit notebook with valuesys.exit()notebookutils.notebook.exit("value")
Mount storageWASB config in spark-defaults.confOneLake Shortcut (no runtime mount needed)

Spark Configuration Differences

HDInsight ConceptFabric Spark EquivalentMigration Action
spark-defaults.conf (cluster-wide)Fabric Spark Workspace Settings + Environment itemMove config properties to Environment or use %%configure in notebooks
%%configure magic%%configure magic — identicalNo change needed
YARN queue / resource allocationFabric Spark pool node size and autoscale settingsMap queue SLAs to Custom Pool configuration
Ambari service configs (HDFS, YARN tuning)Not applicable — Fabric manages infrastructureRemove; focus on application-level Spark configs
HDI Spark version (e.g., Spark 2.4)Fabric Runtime 1.3 = Spark 3.5 (latest)Test for deprecated API removals (e.g., HiveContext, RDD-style ML)
Conda environment / bootstrap.shFabric Environment item with custom librariesRecreate conda/pip dependencies in a Fabric Environment
hive-site.xml (metastore connection)Not needed — Delta Lake IS the metastore in FabricRemove metastore config; use Lakehouse schemas for namespace organization

Must / Prefer / Avoid

MUST DO

  • Replace all wasb:// / wasbs:// paths with OneLake abfss:// paths or OneLake Shortcuts — wasb:// requires storage account keys which are not the Fabric-preferred auth model
  • Replace HiveContext, SQLContext, and standalone SparkContext() — use the pre-instantiated spark session in Fabric notebooks
  • Migrate Hive DDL (STORED AS ORC, LOCATION, TBLPROPERTIES) to Delta Lake DDL — see hive-to-delta.md
  • Introduce notebookutils for file system operations, secret retrieval, and child notebook orchestration where HDInsight used custom scripts or direct API calls
  • Replace Oozie XML workflows with Fabric Data Pipelines — see § Oozie → Fabric Pipelines
  • Align library management to Fabric Environments — remove bootstrap.sh, conda envs, and runtime %pip install patterns for production workloads

PREFER

  • OneLake Shortcuts over copying data — mount existing ADLS Gen2 containers as shortcuts to avoid re-ingestion during migration
  • Delta Lake for all tables migrated from Hive ORC/Parquet — ACID guarantees, time travel, and schema enforcement improve data quality
  • Fabric Starter Pool for initial migration validation — no pool configuration overhead, fast session startup
  • Lakehouse schemas (database namespaces) for organizing migrated Hive databases — one schema per Hive database within a single Lakehouse
  • Medallion architecture for restructuring migrated data layers during migration — align Bronze/Silver/Gold with raw Hive → validated Delta → serving Gold patterns

AVOID

  • Do not use SparkContext() or HiveContext() constructors in Fabric notebooks — they conflict with the pre-instantiated spark session and will raise errors
  • Do not use hive-site.xml or external Hive metastore configuration — Fabric's Delta Lake-backed Lakehouse IS the metastore
  • Do not assume YARN queue mappings translate to Fabric pools — re-design resource allocation based on Fabric Spark pool SLAs
  • Do not attempt to run Oozie shell actions or Java MapReduce jobs directly in Fabric — these must be refactored (see § Oozie → Fabric Pipelines)
  • Do not use %sh magic for file system operations in production notebooks — use notebookutils.fs.* for portability and OneLake token-based auth

Examples

See code-patterns.md for full before/after examples. Key quick references:

Legacy context → Fabric pre-instantiated session

# HDInsight (remove entirely)
from pyspark.sql import HiveContext
hc = HiveContext(sc)

# Fabric — use pre-instantiated spark directly
df = spark.sql("SELECT * FROM sales.fact_orders")

WASB path → OneLake path (after shortcut creation)

# HDInsight
df = spark.read.parquet("wasb://[email protected]/orders/")

# Fabric
df = spark.read.parquet("Files/raw/orders/")

Hive DDL → Delta DDL

-- HDInsight
CREATE TABLE sales_db.fact_orders (...) STORED AS ORC LOCATION 'wasb://...';

-- Fabric
CREATE SCHEMA IF NOT EXISTS sales_db;
CREATE TABLE sales_db.fact_orders (...) USING DELTA;

來自 microsoft 的更多技能

oss-growth
microsoft
開源增長駭客角色
official
microsoft-foundry
microsoft
端到端部署、評估與管理 Foundry 代理:Docker 建置、ACR 推送、託管/提示代理建立、容器啟動、批次評估、持續評估、提示最佳化工作流程、agent.yaml、從追蹤資料集整理。用途:將代理部署至 Foundry、託管代理、建立代理、調用代理、評估代理、執行批次評估、持續評估、持續監控、持續評估狀態、最佳化提示、改善提示、提示最佳化器、最佳化代理指令、改善代理...
officialdevelopmentdevops
azure-ai
microsoft
用於 Azure AI:搜尋、語音、OpenAI、文件智慧。協助搜尋、向量/混合搜尋、語音轉文字、文字轉語音、轉錄、OCR。適用情境:AI 搜尋、查詢搜尋、向量搜尋、混合搜尋、語意搜尋、語音轉文字、文字轉語音、轉錄、OCR、將文字轉換為語音。
officialdevelopmentapi
azure-deploy
microsoft
對已準備好的應用程式執行 Azure 部署,這些應用程式需具備現有的 .azure/deployment-plan.md 與基礎架構檔案。當使用者要求建立新應用程式時,請勿使用此技能——應改用 azure-prepare。此技能會執行 azd up、azd deploy、terraform apply 及 az deployment 命令,並內建錯誤復原機制。需具備來自 azure-prepare 的 .azure/deployment-plan.md,以及來自 azure-validate 的驗證狀態。適用時機:「執行 azd up」、「執行 azd deploy」、「執行部署」……
officialdevopsaws
azure-storage
microsoft
Azure Storage Services 包括 Blob 儲存體、檔案共用、佇列儲存體、表格儲存體和 Data Lake。回答關於儲存存取層(熱、冷、凍結、封存)、各層使用時機及層級比較的問題。提供物件儲存、SMB 檔案共用、非同步訊息、NoSQL 鍵值及大數據分析。包含生命週期管理。用於:blob 儲存體、檔案共用、佇列儲存體、表格儲存體、data lake、上傳檔案、下載 blob、儲存帳戶、存取層...
officialdevelopmentdatabase
azure-diagnostics
microsoft
在 Azure 上使用 AppLens、Azure Monitor、資源健康狀態和安全分類來偵錯 Azure 生產問題。適用時機:偵錯生產問題、疑難排解應用程式服務、應用程式服務高 CPU、應用程式服務部署失敗、疑難排解容器應用程式、疑難排解函數、疑難排解 AKS、kubectl 無法連線、kube-system/CoreDNS 失敗、Pod 擱置、CrashLoop、節點未就緒、升級失敗、分析記錄、KQL、深入解析、映像提取失敗、冷啟動問題、健康狀態探查失敗...
officialdevopsdevelopment
azure-prepare
microsoft
準備 Azure 應用程式以進行部署(基礎架構 Bicep/Terraform、azure.yaml、Dockerfile)。用於建立/現代化或建立+部署;不適用於跨雲端遷移(請使用 azure-cloud-migrate)。請勿用於:copilot-sdk 應用程式(請使用 azure-hosted-copilot-sdk)。適用時機:「建立應用程式」、「建置 Web 應用程式」、「建立 API」、「建立無伺服器 HTTP API」、「建立前端」、「建立後端」、「建置服務」、「現代化應用程式」、「更新應用程式」、「新增驗證」、「新增快取」、「託管於 Azure」、「建立並...」
officialdevelopmentdevops
azure-validate
microsoft
部署前驗證 Azure 就緒狀態。對設定、基礎架構(Bicep 或 Terraform)、RBAC 角色指派、受控身分權限及先決條件進行深度檢查,再進行部署。適用時機:驗證我的應用程式、檢查部署就緒狀態、執行預檢檢查、驗證設定、確認是否可部署、驗證 azure.yaml、驗證 Bicep、部署前測試、疑難排解部署錯誤、驗證 Azure Functions、驗證函式應用程式、驗證無伺服器...
officialdevopstesting