決定運行時間行為的組態設定。
分頁設定
| Property | Default | Description |
|---|---|---|
| runtime.pagination.max-page-size | 定義每頁的記錄上限 | |
| runtime.pagination.default-page-size | 設定每個回應的默認記錄 |
REST 設定
| Property | Default | Description |
|---|---|---|
| 運行時.rest.path | "/api" |
REST 端點的基底路徑 |
| runtime.rest.enabled | true |
允許啟用或停用所有實體的 REST 要求 |
| runtime.rest.request-body-strict | true |
當為 true 時,不允許要求本文中的無關欄位 |
GraphQL 設定
| Property | Default | Description |
|---|---|---|
| runtime.graphql.allow-introspection | true |
允許查詢基礎 GraphQL 架構 |
| runtime.graphql.path | "/graphql" |
GraphQL 端點的基底路徑 |
| runtime.graphql.enabled | true |
允許啟用或停用所有實體的 GraphQL 要求 |
| runtime.graphql.深度限制 | null |
GraphQL 查詢允許的最大深度 |
| runtime.graphql.multiple-mutations.create.enabled | false |
允許針對所有實體進行多重建立突變 |
主機設定
| Property | Default | Description |
|---|---|---|
| runtime.host.max-回應大小-mb | 158 |
單一結果中允許的資料庫回應大小上限 (MB) |
| runtime.host.mode | "production" |
執行模式; "production" 或 "development" |
CORS 設定
| Property | Default | Description |
|---|---|---|
| runtime.host.cors.origins | [] |
允許的 CORS 來源 |
| runtime.host.cors.allow-credentials | false |
設定 Access-Control-Allow-Credentials 標頭的值 |
驗證設定
| Property | Default | Description |
|---|---|---|
| runtime.host.authentication.provider | null |
驗證提供者 |
| runtime.host.authentication.jwt.audience | null |
JWT 對象 |
| runtime.host.authentication.jwt.issuer | null |
JWT 發行者 |
快取設定
| Property | Default | Description |
|---|---|---|
| runtime.cache.enabled | false |
啟用全域回應的快取 |
| runtime.cache.ttl-秒 | 5 |
全域快取的存留時間(秒) |
遙測設置
| Property | Default | Description |
|---|---|---|
| runtime.telemetry.application-insights.connection-string | null |
Application Insights 連接字串 |
| runtime.telemetry.application-insights.enabled | false |
啟用或停用 Application Insights 遙測 |
| runtime.telemetry.open-telemetry.endpoint | null |
OpenTelemetry 收集器 URL |
| runtime.telemetry.open-telemetry.headers | {} |
OpenTelemetry 匯出標頭 |
| runtime.telemetry.open-telemetry.service-name | "dab" |
OpenTelemetry 服務名稱 |
| runtime.telemetry.open-telemetry.exporter-protocol | "grpc" |
OpenTelemetry 通訊協定 (“grpc” 或 “httpprotobuf”) |
| runtime.telemetry.open-telemetry.enabled | true |
啟用或停用 OpenTelemetry |
| runtime.telemetry.log-level.namespace | null |
命名空間特定的記錄層級覆寫 |
| runtime.health.enabled | true |
啟用或停用全域健康情況檢查端點 |
| runtime.health.roles | null |
完整健康情況端點的允許角色 |
| runtime.health.cache-ttl-秒 | 5 |
健康情況檢查報表快取專案的存留時間(秒) |
| runtime.health.max-查詢平行 | 4 |
最大同時健康檢查查詢(範圍:1-8) |
格式概觀
{
"runtime": {
"pagination": {
"max-page-size": <integer|null> (default: `100000`),
"default-page-size": <integer|null> (default: `100`)
},
"rest": {
"path": <string> (default: "/api"),
"enabled": <true>|<false>,
"request-body-strict": <true>|<false> (default: `true`)
},
"graphql": {
"path": <string> (default: "/graphql"),
"enabled": <true>|<false>,
"allow-introspection": <true>|<false>,
"depth-limit": <integer|null> (default: `null`),
"multiple-mutations": {
"create": {
"enabled": <true>|<false> (default: `false`)
}
}
},
"host": {
"mode": <"production"> (default) | <"development">,
"max-response-size-mb": <integer|null> (default: `158`),
"cors": {
"origins": [ "<string>" ],
"allow-credentials": <true>|<false> (default: `false`)
},
"authentication": {
"provider": <string> (default: "AppService"),
"jwt": {
"audience": "<string>",
"issuer": "<string>"
}
}
}
},
"cache": {
"enabled": <true>|<false> (default: `false`),
"ttl-seconds": <integer> (default: `5`)
},
"telemetry": {
"application-insights": {
"connection-string": "<string>",
"enabled": <true>|<false> (default: `true`)
},
"open-telemetry": {
"endpoint": "<string>",
"headers": "<string>",
"service-name": <string> (default: "dab"),
"exporter-protocol": <"grpc"> (default) | <"httpprotobuf">,
"enabled": <true>|<false> (default: `true`)
},
"log-level": {
// namespace keys
"<namespace>": <"trace"|"debug"|"information"|"warning"|"error"|"critical"|"none"|null>
}
},
"health": {
"enabled": <true>|<false> (default: `true`),
"roles": [ "<string>" ],
"cache-ttl-seconds": <integer> (default: `5`),
"max-query-parallelism": <integer> (default: `4`)
}
}
模式 (主機執行時間)
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime |
host |
enum (production | development) |
❌ 否 | production |
開發行為
- Enabled Nitro (先前稱為香蕉蛋糕流行) 用於 GraphQL 測試
- 已啟用用於 REST 測試的 Swagger UI
- 已啟用匿名健康情況檢查
- 增加記錄詳細資訊 (偵錯)
Format
{
"runtime": {
"host": {
"mode": "production" (default) | "development"
}
}
}
回應大小上限 (主機執行時間)
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.host |
max-response-size-mb |
整數 | ❌ 否 | 158 |
設定任何指定結果的大小上限(以 MB 為單位)。 由於大型回應可能會使系統緊張, max-response-size-mb 因此會限制總大小(與數據列計數不同),以防止多載,尤其是文字或 JSON 等大型數據行。
| Value | Result |
|---|---|
| 未設定 | 使用預設值 |
null |
使用預設值 |
integer |
任何正32位整數 |
<= 0 |
不支援 |
Format
{
"runtime": {
"host": {
"max-response-size-mb": <integer; default: 158>
}
}
}
GraphQL (執行時間)
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime |
graphql |
物件 | ❌ 否 | - |
全域 GraphQL 組態。
巢狀屬性
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.graphql |
enabled |
boolean | ❌ 否 | None |
runtime.graphql |
path |
字串 | ❌ 否 | "/graphql" |
runtime.graphql |
depth-limit |
整數 | ❌ 否 | 無(無限制) |
runtime.graphql |
allow-introspection |
boolean | ❌ 否 | True |
runtime.graphql |
multiple-mutations.create.enabled |
boolean | ❌ 否 | False |
屬性附註
- 屬性不允許
path子路徑。 - 使用
depth-limit來限制巢狀查詢。 - 設定
allow-introspection為false以隱藏 GraphQL 架構。 - 用來
multiple-mutations在單一突變中插入多個實體。
Format
{
"runtime": {
"graphql": {
"enabled": <true> (default) | <false>
"depth-limit": <integer|null> (default: `null`),
"path": <string> (default: /graphql),
"allow-introspection": <true> (default) | <false>,
"multiple-mutations": {
"create": {
"enabled": <true> (default) | <false>
}
}
}
}
範例:多個突變
Configuration
{
"runtime": {
"graphql": {
"multiple-mutations": {
"create": {
"enabled": true
}
}
}
},
"entities": {
"User": {
"source": "dbo.Users",
"permissions": [
{
"role": "anonymous",
"actions": ["create"] // entity permissions are required
}
]
}
}
}
GraphQL 突變
mutation {
createUsers(input: [
{ name: "Alice", age: 30, isAdmin: true },
{ name: "Bob", age: 25, isAdmin: false },
{ name: "Charlie", age: 35, isAdmin: true }
]) {
id
name
age
isAdmin
}
}
REST (執行階段)
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime |
rest |
物件 | ❌ 否 | - |
全域 REST 組態。
巢狀屬性
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.rest |
enabled |
boolean | ❌ 否 | None |
runtime.rest |
path |
字串 | ❌ 否 | "/api" |
runtime.rest |
request-body-strict |
boolean | ❌ 否 | True |
屬性附註
- 如果全域
enabled為false,則個別實體層級enabled並不重要。 - 屬性
path不支援子路徑值,例如/api/data。 -
request-body-strict引進有助於簡化 .NET POCO 物件。
request-body-strict |
Behavior |
|---|---|
true |
要求本文中的額外欄位會造成 BadRequest 例外狀況。 |
false |
要求本文中的額外欄位會被忽略。 |
Format
{
"runtime": {
"rest": {
"enabled": <true> (default) | <false>,
"path": <string> (default: /api),
"request-body-strict": <true> (default) | <false>
}
}
}
Note
使用靜態 Web Apps 部署數據 API 產生器時,Azure 服務會自動將另一個子路徑 /data-api 插入 URL。 此行為可確保與現有的靜態 Web 應用程式功能相容。 產生的端點會 /data-api/api/<entity>。 此附注僅與靜態 Web Apps 相關。
範例:request-body-strict
-
default()只有在承載INSERT中的數據行值為 時,才會忽略null具有值的數據行。 因此,當是 時,INSERT資料default()列中的作業無法產生明確的request-body-strict值。truenull若要達成此目的,UPDATE則需要作業。 - 不論承載值為何,都不會忽略
default()具有UPDATE的數據行。 - 計算數據行一律會被忽略。
- 自動產生的數據行一律會被忽略。
範例數據表
CREATE TABLE Users (
Id INT PRIMARY KEY IDENTITY, -- auto-generated column
Name NVARCHAR(50) NOT NULL,
Age INT DEFAULT 18, -- column with default
IsAdmin BIT DEFAULT 0, -- column with default
IsMinor AS IIF(Age <= 18, 1, 0) -- computed column
);
請求載荷
{
"Id": 999,
"Name": "Alice",
"Age": null,
"IsAdmin": null,
"IsMinor": false,
"ExtraField": "ignored"
}
插入行為時機 request-body-strict = false
INSERT INTO Users (Name) VALUES ('Alice');
-- Default values for Age (18) and IsAdmin (0) are applied by the database.
-- IsMinor is ignored because it’s a computed column.
-- ExtraField is ignored.
-- The database generates the Id value.
回應負載
{
"Id": 1, // Auto-generated by the database
"Name": "Alice",
"Age": 18, // Default applied
"IsAdmin": false, // Default applied
"IsMinor": true // Computed
}
更新行為時機 request-body-strict = false
UPDATE Users
SET Name = 'Alice Updated', Age = NULL
WHERE Id = 1;
-- IsMinor and ExtraField are ignored.
回應負載
{
"Id": 1,
"Name": "Alice Updated",
"Age": null,
"IsAdmin": false,
"IsMinor": false // Recomputed by the database (false when age is `null`)
}
CORS (主機執行時間)
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.host |
cors |
物件 | ❌ 否 | - |
全域 CORS 設定。
Tip
CORS 代表「跨原始來源資源分享」。這是一項瀏覽器安全性功能,可控制網頁是否可以對提供給它們的不同網域提出要求。
巢狀屬性
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.host.cors |
allow-credentials |
boolean | ❌ 否 | False |
runtime.host.cors |
origins |
字串陣列 | ❌ 否 | None |
Note
屬性會allow-credentialsAccess-Control-Allow-Credentials設定 CORS 標頭。
Format
{
"runtime": {
"host": {
"cors": {
"allow-credentials": <true> (default) | <false>,
"origins": ["<array-of-strings>"]
}
}
}
}
Note
通配符 * 作為的值 origins有效。
提供者(驗證主機執行時間)
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.host.authentication |
provider |
列舉 (AppService | EntraId | Custom | Simulator) |
❌ 否 | AppService |
定義數據 API 產生器所使用的驗證方法。
僅限匿名 (驗證提供者)
{
"host": {
// omit the authentication section
}
}
當從 dab-config.json 檔案中省略整個 authentication 區段時,不會使用任何驗證提供者。 在此情況下,資料 API 產生器會以「無驗證」模式運作。 在此模式下,DAB 不會尋找任何權杖或 Authorization 標頭。
X-MS-API-ROLE在此配置中也會忽略標頭。
[!註] 進入引擎的每個請求都會自動並立即分配 的
anonymous系統角色。 然後,存取控制會由您在每個實體上定義的許可權專門處理。
實體權限的範例。
{
"entities": {
"Book": {
"source": "dbo.books",
"permissions": [
{
"role": "anonymous",
"actions": [ "read" ]
}
]
}
}
}
在此範例中,由於未設定任何 authentication 提供者,因此所有傳入的要求都會自動視為來自 anonymous 使用者。
permissions實體的Book陣列會明確授與anonymous角色執行作業的能力read。 任何嘗試執行其他動作 (例如 create、 updatedelete、 ) 或存取未設定存取的其他anonymous實體的嘗試都會被拒絕。
StaticWebApps (驗證提供者) [已淘汰]
{
"host": {
"authentication": {
"provider": "StaticWebApps"
}
}
}
此提供者已被取代,因為靜態 Web Apps 預覽功能 Data Connections 已於 2025 年 11 月淘汰。 雖然它仍然有效,但它是為 Azure 靜態 Web Apps 中驗證的舊版實作而設計的。 開發人員應該移轉至 AppService 提供者,以獲得更好的長期支援,並與 Azure 更廣泛的「Easy Auth」平台保持一致。
[!注意] 遷移並不像更改配置文件中的提供商名稱那麼簡單。 和
StaticWebAppsAppService提供者預期標頭內x-ms-client-principal有不同的 JSON 結構來處理角色。
AppService (驗證提供者)
{
"host": {
"authentication": {
"provider": "AppService"
}
}
}
此提供者適用於裝載在 Azure App Service 上的應用程式,例如 Azure 容器應用程式。 Azure 裝載環境會處理驗證,然後透過要求標頭將使用者的身分識別資訊傳遞至應用程式。 它適用於想要由 Azure 平臺管理的簡單、現成可用的驗證解決方案的開發人員。
此提供者不會使用標頭中的 Authorization JWT 權杖。 它依賴 App Service 平臺插入的特殊標頭 X-MS-CLIENT-PRINCIPAL。 此標頭包含一個 base64 編碼的 JSON 物件,其中包含使用者的身分詳細資訊。
匿名:如果已設定提供者,但要求到達時沒有標AppService頭,則X-MS-CLIENT-PRINCIPAL會將要求指派給 的系統角色 anonymous。
標頭解 X-MS-CLIENT-PRINCIPAL 碼的 JSON 通常如下所示:
{
"auth_typ": "aad",
"claims": [
{"typ": "roles", "val": "admin"},
{"typ": "roles", "val": "contributor"}
],
"name_typ": "...",
"role_typ": "..."
}
角色包含在陣列內 claims 。
關於 X-MS-API-ROLE 接頭
-
角色和行為:
X-MS-API-ROLE標頭用於指定使用者想要為目前請求承擔的角色。 此標頭的值必須符合在物件陣claims列中找到X-MS-CLIENT-PRINCIPAL的其中一個角色值。 - 是否必需?:沒有。 如果標頭不存在,則
X-MS-API-ROLE會在系統角色的內容authenticated中處理要求。 這表示使用者會辨識為已登入,但不會辨識為權杖中任何特定的應用程式定義角色。 -
比對行為:如果提供標頭,且其值符合用戶端主體中
X-MS-API-ROLE的角色,使用者claims會擔任要求的該角色。 -
不相符的行為:如果提供標頭,但值不符合用戶端主體中的任何角色,則
X-MS-API-ROLE會拒絕要求,並顯示403 Forbidden狀態碼。 這可確保使用者無法宣告尚未指派的角色。
EntraId (驗證提供者)
{
"host": {
"authentication": {
"provider": "EntraId", // previously AzureAd
"jwt": {
"audience": "00001111-aaaa-2222-bbbb-3333cccc4444",
"issuer": "https://login.microsoftonline.com/98765f43-21ba-400c-a5de-1f2a3d4e5f6a/v2.0"
}
}
}
}
此提供者會使用 Microsoft Entra 中的使用者和應用程式身分識別來保護端點。 它非常適合使用者或其他服務需要在 Entra 租用戶內安全存取的任何服務。
[!註] 該
EntraId提供者先前名為AzureAd。 舊名稱仍然有效,但鼓勵開發人員將其配置從AzureAd遷移到EntraId。
此提供者預期標頭中有 Authorization 標準 JWT 持有人權杖,由 Microsoft Entra 發出。 必須針對特定應用程式設定權杖 (使用 audience 宣告)。 使用者或服務主體的角色預期位於權杖內的宣告中。 程式碼預設會尋找 roles 宣告。
匿名:如果已設定提供者,但要求到達時沒有標EntraId頭,則Authorization會將要求指派給 的系統角色 anonymous。
解碼的 JWT 承載可能如下所示:
{
"aud": "...", // Audience - your API
"iss": "https://login.microsoftonline.com/{tenant-id}/v2.0", // Issuer
"oid": "...", // User or principal object ID
"roles": [
"reader",
"writer"
],
// ... other claims
}
關於 X-MS-API-ROLE 接頭
-
角色和行為:
X-MS-API-ROLE標頭用於指定使用者希望為請求承擔的角色。 此標頭的值必須符合 JWT 權杖宣告中找到roles的其中一個角色值。 - 是否必需?:沒有。 如果標頭不存在,則
X-MS-API-ROLE會在系統角色的內容authenticated中處理要求。 這表示使用者會辨識為已登入,但不會辨識為權杖中任何特定的應用程式定義角色。 -
比對行為:如果提供標頭,且符合宣告中
X-MS-API-ROLE的角色,則roles使用者的內容會設定為該角色。 -
不相符的行為:如果提供標頭,但其值不符合宣告中
X-MS-API-ROLE的任何角色,則roles會拒絕要求,並顯示403 Forbidden狀態碼。 這可確保使用者無法宣告尚未指派的角色。
自訂 (驗證提供者)
{
"host": {
"authentication": {
"provider": "Custom",
"jwt": {
"audience": "<client-id-or-api-audience>",
"issuer": "https://<your-domain>/oauth2/default"
}
}
}
}
此提供者適用於想要將資料 API 產生器與發行 JWT 的第三方身分識別提供者 (例如 Auth0、Okta 或自訂身分識別伺服器) 整合的開發人員。 它提供了配置預期audienceissuer和權杖的靈活性。
Custom提供者預期標頭中有Authorization標準 JWT 持有人權杖。 與提供者的主要 EntraId 差異在於,您在資料 API 產生器的組態檔中設定有效的 issuer 和 audience 。 提供者會檢查授信機構是否發出權杖,以驗證權杖。 使用者的角色預期位於 JWT 承載內的宣告中 roles 。
[!注意] 在某些情況下,視協力廠商身分識別提供者而定,開發人員需要強制其 JWT 的結構,以符合資料 API 產生器預期的結構 (如下所示)。
匿名:如果已設定提供者,但要求到達時沒有標Custom頭,則Authorization會將要求指派給 的系統角色 anonymous。
提供者的 custom 解碼 JWT 承載可能如下所示:
{
"aud": "my-api-audience", // Must match configuration
"iss": "https://my-custom-issuer.com/", // Must match configuration
"sub": "user-id",
"roles": [
"editor",
"viewer"
],
// ... other claims
}
關於 X-MS-API-ROLE 接頭
-
角色和行為:
X-MS-API-ROLE標頭的功能與提供者的功能EntraId完全相同。 它允許使用者選取其指派的角色之一。 此標頭的值必須符合自訂 JWT 權杖中宣roles告中的其中一個角色。 - 是否必需?:沒有。 如果標頭不存在,則
X-MS-API-ROLE會將使用者視為處於系統角色中authenticated。 -
比對行為:如果標頭的值符合 JWT
X-MS-API-ROLE宣告中的角色,則roles使用者的內容會設定為該角色以進行授權。 -
不相符的行為:如果標頭的值與宣告中
X-MS-API-ROLE的任何角色不符,則roles會以狀態碼拒絕403 Forbidden要求。 這可確保使用者無法宣告尚未指派的角色。
模擬器 (驗證提供者)
此提供者旨在讓開發人員輕鬆測試其設定,尤其是 authorization 政策,而無需設定完整的身份驗證提供者,例如 Entra Identity 或 EasyAuth。 它模擬用戶 authenticated 。
Simulator提供者不使用 JWT 權杖。 模擬身份驗證。 使用此提供者時,所有要求都會被視為來自已驗證的使用者。
關於 X-MS-API-ROLE 接頭
-
角色和行為:
X-MS-API-ROLE標頭是使用 .Simulator由於沒有具有角色清單的權杖,因此系統會隱含信任在此標頭中傳送的角色。 - 是否必需?:沒有。
-
不在場時的行為:如果標頭不存在,則
X-MS-API-ROLE會在系統角色的內容authenticated中處理請求。 -
存在時的行為:如果標頭存在,則
X-MS-API-ROLE會在標頭值中指定的角色內容中處理請求。 沒有針對宣告清單進行驗證,因此開發人員可以模擬測試其政策所需的任何角色。
生產中的模擬器
如果設定 authentication.provider 為 Simulator while the runtime.host.mode is production,資料 API 產生器將無法啟動。
"host": {
"mode": "production", // or "development"
"authentication": {
"provider": "Simulator"
}
}
JWT (驗證主機執行時間)
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.host.authentication |
jwt |
物件 | ❌ 否 | - |
全域 JSON Web 令牌 (JWT) 設定。
巢狀屬性
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.host.authentication.jwt |
audience |
字串 | ❌ 否 | None |
runtime.host.authentication.jwt |
issuer |
字串 | ❌ 否 | None |
Format
{
"runtime": {
"host": {
"authentication": {
"jwt": {
"audience": "<client-id>",
"issuer": "<issuer-url>"
}
}
}
}
}
分頁 (執行階段)
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime |
pagination |
物件 | ❌ 否 | - |
REST 和 GraphQL 端點的全域分頁限制。
巢狀屬性
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.pagination |
max-page-size |
int | ❌ 否 | 100,000 |
runtime.pagination |
default-page-size |
int | ❌ 否 | 100 |
runtime.pagination |
next-link-relative |
boolean | ❌ 否 | false |
支援的最大頁面大小值
| Value | Result |
|---|---|
integer |
支援任何正32位整數。 |
0 |
不支援。 |
-1 |
預設為支援的最大值。 |
< -1 |
不支援。 |
默認頁面大小支援的值
| Value | Result |
|---|---|
integer |
小於目前 max-page-size的任何正整數。 |
0 |
不支援。 |
-1 |
預設為目前的 max-page-size 設定。 |
< -1 |
不支援。 |
下一連結相對行為
當 next-link-relative 為 true時,分頁 nextLink 值使用相對網址而非絕對網址。
| Value | Example |
|---|---|
false (預設值) |
"nextLink": "https://localhost:5001/api/users?$after=..." |
true |
"nextLink": "/api/users?$after=..." |
Format
{
"runtime": {
"pagination": {
"max-page-size": <integer; default: 100000>,
"default-page-size": <integer; default: 100>,
"next-link-relative": <boolean; default: false>
}
}
}
Note
當值大於 max-page-size時,結果會限制在 max-page-size。
範例:REST 中的分頁
Request
GET https://localhost:5001/api/users
回應負載
{
"value": [
{
"Id": 1,
"Name": "Alice",
"Age": 30,
"IsAdmin": true,
"IsMinor": false
},
{
"Id": 2,
"Name": "Bob",
"Age": 17,
"IsAdmin": false,
"IsMinor": true
}
],
"nextLink": "https://localhost:5001/api/users?$after=W3siRW50aXR5TmFtZSI6InVzZXJzIiwiRmllbGROYW1lI=="
}
要求下一頁
GET https://localhost:5001/api/users?$after=W3siRW50aXR5TmFtZSI6InVzZXJzIiwiRmllbGROYW1lI==
範例:GraphQL 中的分頁
要求承載 (查詢)
query {
users {
items {
Id
Name
Age
IsAdmin
IsMinor
}
hasNextPage
endCursor
}
}
回應負載
{
"data": {
"users": {
"items": [
{
"Id": 1,
"Name": "Alice",
"Age": 30,
"IsAdmin": true,
"IsMinor": false
},
{
"Id": 2,
"Name": "Bob",
"Age": 17,
"IsAdmin": false,
"IsMinor": true
}
],
"hasNextPage": true,
"endCursor": "W3siRW50aXR5TmFtZSI6InVzZXJzIiwiRmllbGROYW1lI=="
}
}
}
要求下一頁
query {
users(after: "W3siRW50aXR5TmFtZSI6InVzZXJzIiwiRmllbGROYW1lI==") {
items {
Id
Name
Age
IsAdmin
IsMinor
}
hasNextPage
endCursor
}
}
範例:在 max-page-size 要求中存取
將 [REST] 或 max-page-size [GraphQL] 設定$limit為 first,-1以使用 值。
REST
GET https://localhost:5001/api/users?$limit=-1
GraphQL
query {
users(first: -1) {
items {
...
}
}
}
快取 (執行階段)
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime |
cache |
物件 | ❌ 否 | - |
全域快取組態。
巢狀屬性
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.cache |
enabled |
boolean | ❌ 否 | False |
runtime.cache |
ttl-seconds |
整數 | ❌ 否 | 5 |
Tip
實體層級 cache.ttl-seconds 屬性預設為這個全域值。
Format
{
"runtime": {
"cache": {
"enabled": <boolean>,
"ttl-seconds": <integer>
}
}
}
Important
如果全域 enabled 為 false,則個別實體層級 enabled 並不重要。
遙測 (執行階段)
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime |
telemetry |
物件 | ❌ 否 | - |
全域遙測設定。
巢狀屬性
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.telemetry |
log-level |
字典 | ❌ 否 | None |
runtime.telemetry |
application-insights |
物件 | ❌ 否 | - |
runtime.telemetry |
open-telemetry |
物件 | ❌ 否 | - |
設定每個命名空間的記錄詳細資訊。 這會遵循標準 .NET 記錄慣例並允許細微控制,不過它假設對數據 API 產生器內部有一些熟悉。 資料 API 產生器是開放原始碼: https://aka.ms/dab
Format
{
"runtime": {
"telemetry": {
"log-level": {
"namespace": "log-level",
"namespace": "log-level"
}
}
}
}
Tip
log-level 可以在開發和生產環境中進行熱重載。 它目前是唯一支援生產環境中熱重載的屬性。
Example
{
"runtime": {
"telemetry": {
"log-level": {
"Azure.DataApiBuilder.Core.Configurations.RuntimeConfigValidator": "debug",
"Azure.DataApiBuilder.Core": "information",
"default": "warning"
}
}
}
}
Application Insights (遙測)
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.telemetry |
application-insights |
物件 | ❌ 否 | - |
設定記錄至 Application Insights。
巢狀屬性
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.telemetry.application-insights |
enabled |
boolean | ❌ 否 | False |
runtime.telemetry.application-insights |
connection-string |
字串 | ✔️ 是的 | None |
Format
{
"runtime": {
"telemetry": {
"application-insights": {
"enabled": <true; default: true> | <false>
"connection-string": <string>
}
}
}
}
OpenTelemetry (遙測)
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.telemetry |
open-telemetry |
物件 | ❌ 否 | - |
設定記錄以開啟遙測。
巢狀屬性
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime.telemetry.open-telemetry |
enabled |
boolean | ❌ 否 | true |
runtime.telemetry.open-telemetry |
endpoint |
字串 | ✔️ 是的 | None |
runtime.telemetry.open-telemetry |
headers |
字串 | ❌ 否 | None |
runtime.telemetry.open-telemetry |
service-name |
字串 | ❌ 否 | “dab” |
runtime.telemetry.open-telemetry |
exporter-protocol |
enum (grpc | httpprotobuf) |
❌ 否 | grpc |
多個標頭會 , 以逗號分隔。
Format
{
"runtime": {
"telemetry": {
"open-telemetry": {
"enabled": <true> (default) | <false>,
"endpoint": <string>,
"headers": <string>,
"service-name": <string> (default: "dab"),
"exporter-protocol": <"grpc" (default) | "httpprotobuf">
}
}
}
}
Example
{
"runtime": {
"telemetry": {
"open-telemetry": {
"enabled": true,
// a gRPC endpoint example
"endpoint": "http://localhost:4317",
// an HTTP/protobuf endpoint example
"endpoint": "http://localhost:4318/v1/metrics",
"headers": "api-key=key,other-config-value=value",
"service-name": "dab",
}
}
}
}
深入瞭解 OTEL_EXPORTER_OTLP_HEADERS。
Note
gRPC (4317) 更快且支援串流,但需要更多設定。 HTTP/protobuf (4318) 較簡單且更容易偵錯,但效率較低。
健康情況 (執行階段)
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
runtime |
health |
物件 | ❌ 否 | - |
全域 健康情況檢查端點 (/health) 組態。
巢狀屬性
| Parent | Property | 類型 | Required | Default | 音域/註解 |
|---|---|---|---|---|---|
runtime.health |
enabled |
boolean | ❌ 否 | true |
|
runtime.health |
roles |
字串陣列 | ✔️ 是* | null |
*生產模式下必須 |
runtime.health |
cache-ttl-seconds |
整數 | ❌ 否 | 5 |
最小值:0 |
runtime.health |
max-query-parallelism |
整數 | ❌ 否 | 4 |
最小:1,最大:8(夾緊) |
開發與生產環境的行為
| Condition | 開發行為 | 生產行為 |
|---|---|---|
health.enabled = 假 |
403 地位 |
403 地位 |
health.enabled = 真 |
視角色而定 | 視角色而定 |
roles 省略 或 null |
顯示健康情況 |
403 地位 |
目前的角色不在 roles |
403 地位 |
403 地位 |
中目前的角色 roles |
顯示健康情況 | 顯示健康情況 |
roles 包括 anonymous |
顯示健康情況 | 顯示健康情況 |
Format
{
"health": {
"enabled": <true> (default) | <false>,
"roles": [ <string> ], // required in production
"cache-ttl-seconds": <integer; default: 5>,
"max-query-parallelism": <integer; default: 4>
}
}
Note
如果全域 enabled 為 false,則個別實體層級 enabled 並不重要。
Example
{
"health": {
"enabled": true,
"roles": ["admin", "support"],
"cache-ttl-seconds": 10,
"max-query-parallelism": 6
}
}