pac model

用於使用模型驅動應用程式的指令。

Commands

命令 Description
pac model create 創建一個新的模型驅動應用程式。
pac model genpage add 將一個或多個現有生成頁面附加到模型驅動應用程式的網站地圖上(不需重新上傳)。 使用「pac model genpage upload''來建立或更新頁面本身;使用此動詞讓已上傳的頁面在其他應用程式中顯示。
pac model genpage download 從模型驅動的應用程式中拉取產生的頁面。
pac model genpage generate-types 為資料來源產生 TypeScript 架構定義
pac model genpage get-connector-schema 取得產生頁面的連接器表欄位結構或 REST 操作架構。
pac model genpage list 列表生成頁面 — 預設為整個環境,或在提供 --app-id 時針對單一應用程式。 通過 --include-unpublished 也可列出草稿頁面。
pac model genpage list-connector-operations 列出產生頁面的連接器 REST 操作。
pac model genpage list-connector-tables 列出產生頁面的連接器表格。
pac model genpage remove 將現有的生成式 AI 頁面從模型驅動應用程式的網站地圖中分離出來。 Dataverse 中的頁面列會被保留(仍可從其他應用程式引用)。
pac model genpage transpile 將帶有執行時型別的 TypeScript 檔案轉譯,用於測試與除錯
pac model genpage upload 將生成的頁面上傳到 Dataverse 並發佈。 當省略 --page-id 時,會建立新頁面;當提供 --page-ID 時,會更新現有頁面。 若要將環境中已存在的頁面附加到另一個應用程式的網站地圖而無需重新上傳,請改用 'pac model genpage add'。
pac model list 列出環境中所有模型驅動應用程式。
pac model list-languages 清單使 Dataverse 環境中的語言得以啟用。
pac model list-tables 在連接環境中列出 Dataverse 資料表。

pac model create

創建一個新的模型驅動應用程式。

所需參數 model create

--name -n

這是新型號驅動應用程式的顯示名稱。

可選參數 model create

--description -d

新款以模型為驅動的應用程式說明。

--environment -env

指定目標 Dataverse。 值可以是 Guid 或絕對 https URL。 如果未指定,則會使用為目前驗證設定檔選取的作用中組織。

--publish

建立應用程式後再發佈。

此參數不需要任何值。 這是一個開關。

--solution

解決方案:唯一名稱,可以加入應用程式。 若未指定,則預設為「Default」。

pac model create 範例

以下範例展示了常見的使用方式 pac model create

在主動環境中建立新的模型驅動應用程式

pac model create --name "Contoso Sales Hub"

建立一個帶有描述的應用程式,並將其加入解決方案,然後立即發佈

pac model create \
  --name "Contoso Sales Hub" \
  --description "Central hub for managing Contoso sales activities, accounts, and contacts." \
  --solution "ContosoSales" \
  --publish

透過提供環境網址,在特定環境中建立應用程式

pac model create \
  --name "Contoso Sales Hub" \
  --description "Central hub for managing Contoso sales activities, accounts, and contacts." \
  --environment "https://contoso.crm.dynamics.com" \
  --solution "ContosoSales" \
  --publish

Tip

pac model list 來驗證應用程式是被創建的,並取得其應用程式 ID 以便搭配其他指令使用,例如 pac model genpage upload

pac model genpage add

將一個或多個現有生成頁面附加到模型驅動應用程式的網站地圖上(不需重新上傳)。 使用「pac model genpage upload''來建立或更新頁面本身;使用此動詞讓已上傳的頁面在其他應用程式中顯示。

所需參數 model genpage add

--page-id

新增逗號分隔的生成頁面 ID(GUID)到應用程式中。

可選參數 model genpage add

--app-id

模型驅動應用程式的 ID(GUID)。 與 --app-name 互斥。

--app-name

這款以模型為驅動的應用程式獨特名稱。 與 --app-id 互斥。

--area

網站地圖中可選擇放置區域識別碼,將頁面置於下方。 預設是第一個區域。

--environment -env

指定目標 Dataverse。 值可以是 Guid 或絕對 https URL。 如果未指定,則會使用為目前驗證設定檔選取的作用中組織。

--group

網站地圖中可選擇加入群組ID,方便放置該頁面。 預設為所選區域的第一組。

--language-code

子區標題的語言代碼(LCID)。 預設為 1033(en-US)。

--publish

新增頁面後發布模型驅動應用程式。

此參數不需要任何值。 這是一個開關。

--solution

Dataverse 解決方案上下文的唯一名稱,用於 sitemap 更新。 默認為 『Default』。

pac model genpage download

從模型驅動的應用程式中拉取產生的頁面。

所需參數 model genpage download

--app-id

模型驅動應用程式的 ID。

可選參數 model genpage download

--environment -env

指定目標 Dataverse。 值可以是 Guid 或絕對 https URL。 如果未指定,則會使用為目前驗證設定檔選取的作用中組織。

--output-directory -o

目錄用來儲存被拉取的頁面。 預設為目前目錄。

--page-id

要拉取的頁面識別碼清單,並用逗號分隔。

pac model genpage download 範例

以下範例展示了常見的使用方式 pac model genpage download

依照頁面 ID 下載單一生成頁面到本地資料夾進行編輯

pac model genpage download \
  --app-id "a1b2c3d4-1234-5678-abcd-000000000001" \
  --page-id "e5f6a7b8-abcd-ef01-2345-000000000010" \
  --output-directory ./pages/account-dashboard

一次下載應用程式中的所有生成頁面

pac model genpage download \
  --app-id "Contoso Sales Hub" \
  --output-directory ./pages

建立一個以頁面 ID 命名的子目錄,並寫入以下檔案

./pages/account-dashboard/
  e5f6a7b8-abcd-ef01-2345-000000000010/
    page.tsx          ← TypeScript source code
    page.js           ← Transpiled JavaScript
    RuntimeTypes.ts   ← Dataverse type definitions
    config.json       ← Page metadata
    prompt.txt        ← Original generation prompt

pac model genpage generate-types

為資料來源產生 TypeScript 架構定義

所需參數 model genpage generate-types

--data-sources

使用資料來源的逗號分隔清單(例如「帳戶、潛在客戶、聯絡人」)。

可選參數 model genpage generate-types

--environment -env

指定目標 Dataverse。 值可以是 Guid 或絕對 https URL。 如果未指定,則會使用為目前驗證設定檔選取的作用中組織。

--output-file -o

儲存產生的 TypeScript 架構檔案的路徑(預設為 RuntimeTypes.ts)

pac model genpage generate-types 範例

以下範例展示了常見的使用方式 pac model genpage generate-types

產生 TypeScript 類型

為 和 account 表格產生 TypeScript 類型contact,並寫成./src/RuntimeTypes.ts

pac model genpage generate-types \
  --data-sources "account,contact" \
  --output-file ./src/RuntimeTypes.ts

為單一資料表產生特定輸出目錄的型別

pac model genpage generate-types \
  --data-sources "opportunity" \
  --output-file ./pages/opportunity/RuntimeTypes.ts

Note

在撰寫查詢 Dataverse 資料表的頁面程式碼前,務必先執行 generate-types 。 產生的檔案包含強型別欄位名稱、外鍵欄位,以及每個資料表的列舉值。 依賴產生的型別可避免因欄位名稱拼寫錯誤或不存在而導致執行時錯誤。

pac model genpage get-connector-schema

取得產生頁面的連接器表欄位結構或 REST 操作架構。

所需參數 model genpage get-connector-schema

--connection-id

用於尋找連接器元資料的連接 ID。

--connector-id

連接器 API ID(例如 /providers/Microsoft.PowerApps/apis/shared_sharepointonline)。

可選參數 model genpage get-connector-schema

--dataset

用於表格式連接器發現的資料集識別碼(例如 SharePoint 網站 URL 或 SQL 伺服器/資料庫)。 必須使用 ---table 。

--environment -env

指定目標 Dataverse。 值可以是 Guid 或絕對 https URL。 如果未指定,則會使用為目前驗證設定檔選取的作用中組織。

--operation

REST 操作識別碼用於操作結構模式。 無法與 --dataset 或 --table 一起使用。

--table

表格結構模式的表格識別碼。 需要 --dataset,且無法搭配 --操作使用。

pac model genpage list

列表生成頁面 — 預設為整個環境,或在提供 --app-id 時針對單一應用程式。 通過 --include-unpublished 也可列出草稿頁面。

可選參數 model genpage list

--app-id

模型驅動應用程式的 ID。

--environment -env

指定目標 Dataverse。 值可以是 Guid 或絕對 https URL。 如果未指定,則會使用為目前驗證設定檔選取的作用中組織。

--include-unpublished

在列表中包含未發表的生成頁面(預設:僅已發佈)。

此參數不需要任何值。 這是一個開關。

pac model genpage list 範例

以下範例展示了常見的使用方式 pac model genpage list

使用 App ID 的清單頁面

請使用其應用程式 ID 列出 Contoso Sales Hub 應用程式中的所有生成頁面:

pac model genpage list --app-id "a1b2c3d4-1234-5678-abcd-000000000001"

使用應用程式名稱的列表頁面

依應用程式名稱列出生成頁面(CLI 會自動查詢應用程式 ID):

pac model genpage list --app-id "Contoso Sales Hub"

pac model Genpage 範例輸出

Found 2 generated page(s):

  Account Dashboard
    Page ID: e5f6a7b8-abcd-ef01-2345-000000000010
    Description: Created: 2026-01-15T10:22:00Z

  Opportunity Tracker
    Page ID: e5f6a7b8-abcd-ef01-2345-000000000011
    Description: Created: 2026-02-03T14:05:00Z

pac model genpage list-connector-operations

列出產生頁面的連接器 REST 操作。

所需參數 model genpage list-connector-operations

--connection-id

用於尋找連接器元資料的連接 ID。

--connector-id

連接器 API ID(例如 /providers/Microsoft.PowerApps/apis/shared_sharepointonline)。

可選參數 model genpage list-connector-operations

--environment -env

指定目標 Dataverse。 值可以是 Guid 或絕對 https URL。 如果未指定,則會使用為目前驗證設定檔選取的作用中組織。

pac model genpage list-connector-tables

列出產生頁面的連接器表格。

所需參數 model genpage list-connector-tables

--connection-id

用於尋找連接器元資料的連接 ID。

--connector-id

連接器 API ID(例如 /providers/Microsoft.PowerApps/apis/shared_sharepointonline)。

可選參數 model genpage list-connector-tables

--dataset

用於表格式連接器發現的資料集識別碼(例如 SharePoint 網站 URL 或 SQL 伺服器/資料庫)。 必須使用 ---table 。

--environment -env

指定目標 Dataverse。 值可以是 Guid 或絕對 https URL。 如果未指定,則會使用為目前驗證設定檔選取的作用中組織。

pac model genpage remove

將現有的生成式 AI 頁面從模型驅動應用程式的網站地圖中分離出來。 Dataverse 中的頁面列會被保留(仍可從其他應用程式引用)。

所需參數 model genpage remove

--page-id

一個或多個 uxagentproject ID 要移除(逗號分隔)。

可選參數 model genpage remove

--app-id

模型驅動應用程式 ID(uniqueid)來移除該頁面。 與 --app-name 互斥。

--app-name

模型驅動的應用程式唯一名稱,可移除該頁面。 與 --app-id 互斥。

--environment -env

指定目標 Dataverse。 值可以是 Guid 或絕對 https URL。 如果未指定,則會使用為目前驗證設定檔選取的作用中組織。

--publish

在網站地圖編輯完成後發布模型驅動的應用程式,讓變更立即上線。

此參數不需要任何值。 這是一個開關。

--solution

Dataverse 解決方案是 sitemap 更新的唯一名稱。 默認為 『Default』。

pac model genpage transpile

將帶有執行時型別的 TypeScript 檔案轉譯,用於測試與除錯

所需參數 model genpage transpile

--code-file

包含頁面代碼的檔案路徑。

可選參數 model genpage transpile

--data-sources

使用資料來源的逗號分隔清單(例如「帳戶、潛在客戶、聯絡人」)。

--environment -env

指定目標 Dataverse。 值可以是 Guid 或絕對 https URL。 如果未指定,則會使用為目前驗證設定檔選取的作用中組織。

--output-file

儲存轉譯後 JavaScript 輸出的路徑(預設為 [code-file].compiled.js)

pac model genpage upload

將生成的頁面上傳到 Dataverse 並發佈。 當省略 --page-id 時,會建立新頁面;當提供 --page-ID 時,會更新現有頁面。 若要將環境中已存在的頁面附加到另一個應用程式的網站地圖而無需重新上傳,請改用 'pac model genpage add'。

所需參數 model genpage upload

--app-id

模型驅動應用程式的 ID。

--code-file

包含頁面代碼的檔案路徑。

可選參數 model genpage upload

--add-to-sitemap

將該頁面加入應用程式的網站地圖導覽。

此參數不需要任何值。 這是一個開關。

--agent-message

代理人的回覆訊息。

--agent-message-file

路徑指向包含代理回應訊息的檔案。

--compiled-code-file

包含已編譯 JavaScript 程式碼的檔案路徑。 若未提供,TypeScript 將自動轉譯為 JavaScript。

--connectors

指向帶有連接器綁定的 JSON 檔案路徑,以持續存在於頁面的 config.json。

--data-sources

使用資料來源的逗號分隔清單(例如「帳戶、潛在客戶、聯絡人」)。

--environment -env

指定目標 Dataverse。 值可以是 Guid 或絕對 https URL。 如果未指定,則會使用為目前驗證設定檔選取的作用中組織。

--model

用於產生該頁面的 AI 模型(例如 'claude-3-5-sonnet-20241022')。

--name -n

頁面名稱。

--page-id

頁面的 ID 要更新。 若未提供,將建立新頁面。

--prompt

產生此頁面的使用者提示。

--prompt-file

指向包含產生此頁面的使用者提示的檔案路徑。

pac model genpage upload 範例

以下範例展示了常見的使用方式 pac model genpage upload

發佈新的生成頁面

將新的生成頁面發佈到 Contoso Sales Hub 應用程式,並將其加入應用程式網站地圖:

pac model genpage upload \
  --app-id "a1b2c3d4-1234-5678-abcd-000000000001" \
  --code-file ./pages/account-dashboard.tsx \
  --name "Account Dashboard" \
  --data-sources "account,contact" \
  --prompt "A dashboard showing Account records as interactive cards with contact count and revenue metrics." \
  --model "claude-sonnet-4-6" \
  --agent-message "Created account dashboard with card grid, revenue chart, and contact list. Uses account and contact tables." \
  --add-to-sitemap

更新現有的生成頁面

透過提供現有生成頁面的頁面 ID(省 --add-to-sitemap 略以避免產生重複的網站地圖條目):

pac model genpage upload \
  --app-id "a1b2c3d4-1234-5678-abcd-000000000001" \
  --page-id "e5f6a7b8-abcd-ef01-2345-000000000010" \
  --code-file ./pages/account-dashboard.tsx \
  --data-sources "account,contact" \
  --prompt "A dashboard showing Account records as interactive cards with contact count and revenue metrics." \
  --model "claude-sonnet-4-6" \
  --agent-message "Updated card layout to use a two-column grid; added revenue sparkline chart."

發佈使用模擬資料的頁面

發佈使用模擬資料的頁面(不含 Dataverse 表格——省略 --data-sources):

pac model genpage upload \
  --app-id "Contoso Sales Hub" \
  --code-file ./pages/welcome-screen.tsx \
  --name "Welcome" \
  --prompt "A branded welcome screen with Contoso logo, quick-action tiles, and a news feed placeholder." \
  --model "claude-sonnet-4-6" \
  --agent-message "Welcome page with static mock data. No Dataverse queries." \
  --add-to-sitemap

Tip

參數 --app-id 接受應用程式的 GUID 或顯示名稱。 如果多個應用程式共用相同顯示名稱,請使用 GUID 以避免歧義。 跑去 pac model list 查應用程式 ID。

pac model genpage upload 參數快速參照

參數 Required Description
--app-id 是的 應用程式的 GUID 或顯示名稱。 快去 pac model list 找。
--code-file 是的 部署到原始檔案的路徑 .tsx
--name 僅限新頁面 顯示名稱會顯示在應用程式的網站地圖中。
--page-id 僅更新 要替換現有頁面的 GUID。
--data-sources Dataverse 頁面 以逗號分隔的 Dataverse 資料表邏輯名稱列表(例如 "account,contact")。
--prompt 建議使用 頁面功能的自然語言摘要。 儲存以供再生背景使用。
--model 建議使用 用於產生頁面的模型 ID(例如 claude-sonnet-4-6)。
--agent-message 建議使用 描述建造或改動的部分。 儲存在變更歷史紀錄中。
--add-to-sitemap 僅限新頁面 會自動將該頁面加入應用程式導覽。 更新時省略。

pac model list

列出環境中所有模型驅動應用程式。

可選參數 model list

--environment -env

指定目標 Dataverse。 值可以是 Guid 或絕對 https URL。 如果未指定,則會使用為目前驗證設定檔選取的作用中組織。

pac model list 範例

列出目前活躍環境中所有模型驅動應用程式:

pac model list

範例輸出:

Found 3 model-driven app(s):

  Contoso Sales Hub
    App ID: a1b2c3d4-1234-5678-abcd-000000000001
    Unique Name: contoso_SalesHub

  Contoso Field Service
    App ID: a1b2c3d4-1234-5678-abcd-000000000002
    Unique Name: contoso_FieldService

  Contoso Customer Portal
    App ID: a1b2c3d4-1234-5678-abcd-000000000003
    Unique Name: contoso_CustomerPortal

pac model list-languages

清單使 Dataverse 環境中的語言得以啟用。

可選參數 model list-languages

--environment -env

指定目標 Dataverse。 值可以是 Guid 或絕對 https URL。 如果未指定,則會使用為目前驗證設定檔選取的作用中組織。

pac model list-tables

在連接環境中列出 Dataverse 資料表。

可選參數 model list-tables

--environment -env

指定目標 Dataverse。 值可以是 Guid 或絕對 https URL。 如果未指定,則會使用為目前驗證設定檔選取的作用中組織。

--search -s

以逗號分隔的搜尋名稱清單(與邏輯名稱、結構名稱或顯示名稱相符)。

--type -t

依表格類型篩選:「自訂」、「標準」或「全部」(預設:全部)。

參見

Microsoft Power Platform CLI 指令群組
Microsoft Power Platform CLI 概述