Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
In data-source de sectie worden de details van de databasetoegang gedefinieerd. Er worden ook databaseopties gedefinieerd.
Gegevensbroninstellingen
| Property | Description |
|---|---|
| data-source | Object met databaseconnectiviteitsinstellingen |
| data-source.database-type | Database die wordt gebruikt in de back-end: mssql, postgresql, mysql, cosmosdb_nosqlcosmosdb_postgresql |
| data-source.connection-string | Verbindingsreeks voor het geselecteerde databasetype |
| data-source.options | Databasespecifieke eigenschappen (bijvoorbeeld opties voor SQL Server, Cosmos DB, enzovoort) |
| data-source.options.database | Naam van de Azure Cosmos DB for NoSQL-database (vereist wanneer database-type = cosmosdb_nosql) |
| data-source.options.container | Naam van de Azure Cosmos DB for NoSQL-container (vereist wanneer database-type = cosmosdb_nosql) |
| data-source.options.schema | Pad naar het GraphQL-schemabestand (vereist wanneer database-type = cosmosdb_nosql) |
| data-source.options.set-session-context | Hiermee schakelt u het verzenden van JSON-webtokenclaims (JWT) in als sessiecontext (alleen SQL Server) |
| data-source.health | Object configureren van statuscontroles voor de gegevensbron |
| data-source.health.enabled | Hiermee schakelt u het eindpunt van de statuscontrole in |
| data-source.health.name | Id die wordt gebruikt in het statusrapport |
| data-source.health.threshold-ms | Maximale duur in milliseconden voor statuscontrolequery |
Format overview
{
"data-source": {
"database-type": <string>,
"connection-string": <string>,
"options": {
// mssql only
"set-session-context": <true> (default) | <false>,
// cosmosdb_nosql only
"database": <string>,
"container": <string>,
"schema": <string>
},
"health": {
"enabled": <true> (default) | <false>,
"name": <string>,
"threshold-ms": <integer; default: 1000>
}
},
"data-source-files": ["<string>"]
}
Data source
| Parent | Property | Type | Required | Default |
|---|---|---|---|---|
$root |
database-source |
object | ✔️ Yes | - |
Nested properties
| Parent | Property | Type | Required | Default |
|---|---|---|---|---|
data-source |
database-type |
enum | ✔️ Yes | None |
data-source |
connection-string |
string | ✔️ Yes | None |
data-source |
options |
object | ❌ Nee | None |
Property values
database-type |
Description | Min Version |
|---|---|---|
mssql |
SQL in Fabric | - |
mssql |
Azure SQL Database | - |
mssql |
Azure SQL MI | - |
mssql |
SQL Server | 2016 |
dwsql |
Azure Synapse Analytics | - |
dwsql |
Fabric Warehouse | - |
dwsql |
Sql Analytics-eindpunt voor fabric | - |
postgresql |
PostgreSQL | ver. 11 |
mysql |
MySQL | ver. 8 |
cosmosdb_nosql |
Azure Cosmos DB voor NoSQL | - |
cosmosdb_postgresql |
Azure Cosmos DB voor PostgreSQL | - |
Format
{
"data-source": {
"database-type": <string>,
"connection-string": <string>,
"options": {
"<key-name>": <string>
}
}
}
Voorbeeld: Azure SQL & SQL Server
"data-source": {
"database-type": "mssql",
"connection-string": "Server=tcp:myserver.database.windows.net,1433;Initial Catalog=MyDatabase;User ID=MyUser;Password=MyPassword;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
"options": {
"set-session-context": true
}
}
Note
We use SqlClient for Azure SQL and SQL Server, which supports these connection strings variants.
Consumeren SESSION_CONTEXT
Voor Azure SQL en SQL Server kan Data API Builder claimgegevens bevatten in SQL SESSION_CONTEXT.
CREATE PROC GetUser @userId INT AS
BEGIN
-- Use claims
IF SESSION_CONTEXT(N'user_role') = 'admin'
BEGIN
RAISERROR('Unauthorized access', 16, 1);
END
SELECT Id, Name, Age, IsAdmin
FROM Users
WHERE Id = @userId;
END;
Voorbeeld: Azure Cosmos DB
"data-source": {
"database-type": "cosmosdb_nosql",
"connection-string": "@env('SQL_CONNECTION_STRING')",
"options": {
"database": "Your_CosmosDB_Database_Name",
"container": "Your_CosmosDB_Container_Name",
"schema": "Path_to_Your_GraphQL_Schema_File"
}
}
Note
De opgegeven opties (database, containeren schema) zijn specifiek voor Azure Cosmos DB.
Environment variables
Gebruik omgevingsvariabelen om geheimen zonder opmaak buiten uw configuratiebestand te houden.
Tip
Data API Builder ondersteunt beide @env() bestanden van function.env](../reference-functions.md#env) and [.
"data-source": {
"database-type": "mssql",
"connection-string": "@env('SQL_CONNECTION_STRING')"
}
Connection resiliency
Data API Builder maakt gebruik van Exponential Backoff om databaseaanvragen opnieuw uit te voeren na tijdelijke fouten.
| Attempts | First | Second | Third | Fourth | Fifth |
|---|---|---|---|---|---|
| Seconds | 2s | 4s | 8s | 16s | 32s |
Managed Service Identities (MSI)
Managed Service Identities (MSI) worden ondersteund met DefaultAzureCredential gedefinieerde bibliotheek Azure.Identity . Meer informatie over beheerde identiteiten in Microsoft Entra voor Azure SQL.
User-Assigned Beheerde identiteiten (UAMI)
For User Assigned Managed Identity, append the Authentication and User Id properties to your connection string while substituting in your User Assigned Managed Identity's client id: Authentication=Active Directory Managed Identity; User Id=<UMI_CLIENT_ID>;.
System-Assigned Managed Identity (SAMI)
For System Assigned Managed Identity, append the Authentication property and exclude the UserId and Password arguments from your connection string: Authentication=Active Directory Managed Identity;.
Status (gegevensbron)
| Parent | Property | Type | Required | Default |
|---|---|---|---|---|
data-source |
health |
object | No | – |
Data API Builder ondersteunt meerdere configuratiebestanden, elk met een eigen gegevensbron. Met dit configuratieblok kan elke gegevensbron een eigen statusconfiguratie hebben.
Nested properties
| Parent | Property | Type | Required | Default |
|---|---|---|---|---|
data-source.health |
enabled |
boolean | No | true |
data-source.health |
name |
string | No | database-type |
data-source.health |
threshold-ms |
integer | No | 1000 |
Check name
Omdat meerdere configuratiebestanden naar gegevensbronnen van hetzelfde type kunnen verwijzen, kunnen deze gegevensbronnen niet worden onderscheiden in het statusrapport. Gebruik name dit om een uniek, identificeerbaar label toe te wijzen dat alleen in het statusrapport wordt gebruikt.
Check behavior
De eenvoudigste query, specifiek voor het databasetype, wordt uitgevoerd op basis van de opgegeven gegevensbron om te controleren of de verbinding kan worden geopend. Gebruik de threshold-ms eigenschap om de maximaal acceptabele duur (in milliseconden) voor die query te configureren.
Format
{
"data-source": {
"health": {
"enabled": <true> (default) | <false>,
"name": <string>,
"threshold-ms": <integer; default: 1000>
}
}
}