Use identity-based authentication for Cogitive Services accounts#
Security · Cognitive Services · 2022_09
Authenticate requests to Cognitive Services with Azure AD identities.
Description#
To send requests to Cognitive Services endpoints, each request must include an authentication header. Cognitive Services endpoints supports authentication with keys or tokens. Using an Azure AD token instead of a cryptographic key has some additional security benefits.
With Azure AD authentication, the identity is validated against Azure AD identity provider. Using Azure AD identities centralizes identity management and auditing.
Once you decide to use Azure AD authentication, you can disable authentication using keys.
Recommendation#
Consider only using Azure AD identities to authenticate requests to Cogitive Services accounts. Once configured, disable authentication based on access keys.
Examples#
Configure with Azure template#
To deploy accounts that pass this rule:
- Set the
properties.disableLocalAuth
property totrue
.
For example:
{
"type": "Microsoft.CognitiveServices/accounts",
"apiVersion": "2022-03-01",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"identity": {
"type": "SystemAssigned"
},
"sku": {
"name": "S0"
},
"kind": "CognitiveServices",
"properties": {
"publicNetworkAccess": "Disabled",
"networkAcls": {
"defaultAction": "Deny"
},
"disableLocalAuth": true
}
}
Configure with Bicep#
To deploy accounts that pass this rule:
- Set the
properties.disableLocalAuth
property totrue
.
For example:
resource account 'Microsoft.CognitiveServices/accounts@2022-03-01' = {
name: name
location: location
identity: {
type: 'SystemAssigned'
}
sku: {
name: 'S0'
}
kind: 'CognitiveServices'
properties: {
publicNetworkAccess: 'Disabled'
networkAcls: {
defaultAction: 'Deny'
}
disableLocalAuth: true
}
}
Links#
- Use identity-based authentication
- Authenticate with Azure Active Directory
- Azure Policy built-in policy definitions for Azure Cognitive Services
- Azure deployment reference