Skip to content

Commit

Permalink
[Language Text] Improve test-resources.json (Azure#24301)
Browse files Browse the repository at this point in the history
Enables custom text feature in dynamically-generated language resources by creating a storage account and linking it to the language resource.
  • Loading branch information
deyaaeldeen authored Dec 21, 2022
1 parent 350424f commit 8f1a4a9
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sdk/cognitivelanguage/ai-language-text/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ parameters:
- name: Location
displayName: Location
type: string
default: uksouth
default: eastus

trigger: none

Expand Down
173 changes: 159 additions & 14 deletions sdk/cognitivelanguage/test-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@
"testApplicationOid": {
"type": "string",
"metadata": {
"description": "The AAD Client ID of the test application service principal."
"description": "The client OID to grant access to test resources."
}
},
"tenantId": {
"type": "string",
"defaultValue": "72f988bf-86f1-41af-91ab-2d7cd011db47",
"metadata": {
"description": "The tenant id to which the application and resources belong."
"description": "The tenant ID to which the application and resources belong."
}
},
"testApplicationId": {
"type": "string",
"metadata": {
"description": "The application client id used to run tests."
"description": "The application client ID used to run tests."
}
},
"testApplicationSecret": {
Expand All @@ -42,39 +43,179 @@
"description": "The application client secret used to run tests."
}
},
"enableVersioning": {
"type": "bool",
"defaultValue": false
},
"cognitiveServicesEndpointSuffix": {
"type": "string",
"defaultValue": ".cognitiveservices.azure.com"
}
},
"variables": {
"taRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/a97b65f3-24c7-4388-baec-2e87135dc908')]",
"accountName": "[format('textanalytics-{0}', parameters('baseName'))]"
"cognitiveAccountName": "[format('textanalytics-{0}', parameters('baseName'))]",
"cognitiveApiVersion": "2022-12-01",
"storageApiVersion": "2022-09-01",
"storageAccountName": "[parameters('baseName')]",
"authorizationApiVersion": "2018-09-01-preview",
"blobDataContributorRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe')]",
"blobDataOwnerRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/b7e6dc6d-f1e8-4753-8033-0f276bb0955b')]",
"encryption": {
"services": {
"file": {
"enabled": true
},
"blob": {
"enabled": true
}
},
"keySource": "Microsoft.Storage"
},
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [],
"ipRules": [],
"defaultAction": "Allow"
},
"containerName": "documents"
},
"resources": [
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "[variables('authorizationApiVersion')]",
"name": "[guid(concat('blobDataContributorRoleId', variables('storageAccountName')))]",
"dependsOn": ["[variables('storageAccountName')]"],
"properties": {
"roleDefinitionId": "[variables('blobDataContributorRoleId')]",
"principalId": "[parameters('testApplicationOid')]"
}
},
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "[variables('authorizationApiVersion')]",
"name": "[guid(concat('blobDataOwnerRoleId', variables('storageAccountName')))]",
"dependsOn": ["[variables('storageAccountName')]"],
"properties": {
"roleDefinitionId": "[variables('blobDataOwnerRoleId')]",
"principalId": "[parameters('testApplicationOid')]"
}
},
{
"type": "Microsoft.CognitiveServices/accounts/providers/roleAssignments",
"apiVersion": "2018-09-01-preview",
"name": "[format('{0}/Microsoft.Authorization/{1}', variables('accountName'), guid(variables('accountName')))]",
"apiVersion": "[variables('authorizationApiVersion')]",
"name": "[format('{0}/Microsoft.Authorization/{1}', variables('cognitiveAccountName'), guid(variables('cognitiveAccountName')))]",
"dependsOn": [
"[resourceId('Microsoft.CognitiveServices/accounts', variables('accountName'))]"
"[resourceId('Microsoft.CognitiveServices/accounts', variables('cognitiveAccountName'))]"
],
"properties": {
"principalId": "[parameters('testApplicationOid')]",
"roleDefinitionId": "[variables('taRoleId')]"
}
},
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "[variables('storageApiVersion')]",
"name": "[variables('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"networkAcls": "[variables('networkAcls')]",
"supportsHttpsTrafficOnly": true,
"encryption": "[variables('encryption')]",
"accessTier": "Hot"
},
"resources": [
{
"name": "default",
"type": "blobServices",
"apiVersion": "[variables('storageApiVersion')]",
"dependsOn": ["[variables('storageAccountName')]"],
"properties": {
"isVersioningEnabled": "[parameters('enableVersioning')]",
"cors": {
"corsRules": [
{
"allowedOrigins": ["*"],
"allowedMethods": [
"DELETE",
"GET",
"HEAD",
"MERGE",
"POST",
"OPTIONS",
"PUT",
"PATCH"
],
"maxAgeInSeconds": 86400,
"exposedHeaders": ["*"],
"allowedHeaders": ["*"]
}
]
},
"lastAccessTimeTrackingPolicy": {
"enable": true,
"name": "AccessTimeTracking",
"trackingGranularityInDays": 1,
"blobType": ["blockBlob"]
}
},
"resources": []
},
{
"name": "default",
"type": "fileServices",
"apiVersion": "[variables('storageApiVersion')]",
"dependsOn": ["[variables('storageAccountName')]"],
"properties": {
"cors": {
"corsRules": [
{
"allowedOrigins": ["*"],
"allowedMethods": ["DELETE", "GET", "HEAD", "MERGE", "POST", "OPTIONS", "PUT"],
"maxAgeInSeconds": 86400,
"exposedHeaders": ["*"],
"allowedHeaders": ["*"]
}
]
}
},
"resources": []
}
]
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"apiVersion": "[variables('storageApiVersion')]",
"name": "[format('{0}/default/{1}', variables('storageAccountName'), variables('containerName'))]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
},
{
"type": "Microsoft.CognitiveServices/accounts",
"name": "[variables('accountName')]",
"apiVersion": "2017-04-18",
"name": "[variables('cognitiveAccountName')]",
"apiVersion": "[variables('cognitiveApiVersion')]",
"sku": {
"name": "S"
},
"kind": "TextAnalytics",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
],
"properties": {
"customSubDomainName": "[variables('accountName')]"
"customSubDomainName": "[variables('cognitiveAccountName')]",
"userOwnedStorage": [{
"resourceId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
}]
},
"identity": {
"type": "SystemAssigned"
}
}
],
Expand All @@ -93,15 +234,19 @@
},
"LANGUAGE_API_KEY": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('accountName')), '2017-04-18').key1]"
"value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('cognitiveAccountName')), variables('cognitiveApiVersion')).key1]"
},
"LANGUAGE_API_KEY_ALT": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('accountName')), '2017-04-18').key2]"
"value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('cognitiveAccountName')), variables('cognitiveApiVersion')).key2]"
},
"ENDPOINT": {
"type": "string",
"value": "[concat('https://', variables('accountName'), parameters('cognitiveServicesEndpointSuffix'), '/')]"
"value": "[concat('https://', variables('cognitiveAccountName'), parameters('cognitiveServicesEndpointSuffix'), '/')]"
},
"STORAGE_ACCOUNT_NAME": {
"type": "string",
"value": "[variables('storageAccountName')]"
}
}
}
}

0 comments on commit 8f1a4a9

Please sign in to comment.