您可以使用驗證配置搭配從 Microsoft Entra ID 取得的權杖來 Bearer 驗證 HTTP 要求。 您必須透過傳輸層安全性 (TLS) 傳輸這些要求。
先決條件
您必須將用來要求 Microsoft Entra 權杖的主體指派給其中一個適用的 Azure 應用程式設定角色。
為每個請求提供身份驗證所需的所有 HTTP 標頭。 以下是最低要求:
| 要求標頭 | Description |
|---|---|
Authorization |
配置所需的 Bearer 驗證資訊。 |
Example:
Host: {myconfig}.azconfig.io
Authorization: Bearer {{AadToken}}
Microsoft Entra 權杖取得
取得 Microsoft Entra 權杖之前,您必須識別您要驗證為哪個使用者、您要求權杖的對象,以及要使用的 Microsoft Entra 端點 (授權單位)。
觀眾
要求具有適當對象的 Microsoft Entra 權杖。 對象也可以稱為要求權杖的 資源 。
針對全域 Azure 雲端中的 Azure 應用程式設定,請使用下列物件:
https://appconfig.azure.com
針對國家雲端中的 Azure 應用程式設定,請使用下表中指定的適用物件:
| 國家雲 | 觀眾 |
|---|---|
| Azure Government | https://appconfig.azure.us |
| 由 21Vianet 營運的 Microsoft Azure | https://appconfig.azure.cn |
| 藍調 | https://appconfig.sovcloud-api.fr |
Microsoft Entra 授權單位
Microsoft Entra 授權單位是您用來取得 Microsoft Entra 權杖的端點。 針對全域 Azure 雲端,其形式 https://login.microsoftonline.com/{tenantId}為 。 區 {tenantId} 段是指嘗試驗證的使用者或應用程式所屬的 Microsoft Entra 租用戶識別碼。
Azure 國家雲端有不同的 Microsoft Entra 驗證端點。 請參閱 Microsoft Entra 驗證端點 要在國家雲端中使用的端點。
驗證程式庫
Microsoft 驗證程式庫 (MSAL) 有助於簡化取得 Microsoft Entra 權杖的程式。 Azure 會針對多種語言建置這些程式庫。 如需詳細資訊,請參閱 文件。
Errors
您可能會遇到下列錯誤。
HTTP/1.1 401 Unauthorized
WWW-Authenticate: HMAC-SHA256, Bearer
緣: 您尚未提供配置的 Bearer 授權要求標頭。
溶液: 提供有效的 Authorization HTTP 要求標頭。
HTTP/1.1 401 Unauthorized
WWW-Authenticate: HMAC-SHA256, Bearer error="invalid_token", error_description="Authorization token failed validation"
緣: Microsoft Entra 權杖無效。
溶液: 從 Microsoft Entra 授權單位取得 Microsoft Entra 權杖,並確定您已使用適當的物件。
HTTP/1.1 401 Unauthorized
WWW-Authenticate: HMAC-SHA256, Bearer error="invalid_token", error_description="The access token is from the wrong issuer. It must match the AD tenant associated with the subscription to which the configuration store belongs. If you just transferred your subscription and see this error message, please try back later."
緣: Microsoft Entra 權杖無效。
溶液: 從 Microsoft Entra 授權單位取得 Microsoft Entra 權杖。 請確定 Microsoft Entra 租用戶是與組態存放區所屬訂用帳戶相關聯的租用戶。 如果主體屬於多個 Microsoft Entra 租用戶,則可能會出現此錯誤。