Skip to content

Commit 8f1a4a9

Browse files
authored
[Language Text] Improve test-resources.json (Azure#24301)
Enables custom text feature in dynamically-generated language resources by creating a storage account and linking it to the language resource.
1 parent 350424f commit 8f1a4a9

File tree

2 files changed

+160
-15
lines changed

2 files changed

+160
-15
lines changed

sdk/cognitivelanguage/ai-language-text/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ parameters:
22
- name: Location
33
displayName: Location
44
type: string
5-
default: uksouth
5+
default: eastus
66

77
trigger: none
88

sdk/cognitivelanguage/test-resources.json

Lines changed: 159 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,20 @@
2121
"testApplicationOid": {
2222
"type": "string",
2323
"metadata": {
24-
"description": "The AAD Client ID of the test application service principal."
24+
"description": "The client OID to grant access to test resources."
2525
}
2626
},
2727
"tenantId": {
2828
"type": "string",
29+
"defaultValue": "72f988bf-86f1-41af-91ab-2d7cd011db47",
2930
"metadata": {
30-
"description": "The tenant id to which the application and resources belong."
31+
"description": "The tenant ID to which the application and resources belong."
3132
}
3233
},
3334
"testApplicationId": {
3435
"type": "string",
3536
"metadata": {
36-
"description": "The application client id used to run tests."
37+
"description": "The application client ID used to run tests."
3738
}
3839
},
3940
"testApplicationSecret": {
@@ -42,39 +43,179 @@
4243
"description": "The application client secret used to run tests."
4344
}
4445
},
46+
"enableVersioning": {
47+
"type": "bool",
48+
"defaultValue": false
49+
},
4550
"cognitiveServicesEndpointSuffix": {
4651
"type": "string",
4752
"defaultValue": ".cognitiveservices.azure.com"
4853
}
4954
},
5055
"variables": {
5156
"taRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/a97b65f3-24c7-4388-baec-2e87135dc908')]",
52-
"accountName": "[format('textanalytics-{0}', parameters('baseName'))]"
57+
"cognitiveAccountName": "[format('textanalytics-{0}', parameters('baseName'))]",
58+
"cognitiveApiVersion": "2022-12-01",
59+
"storageApiVersion": "2022-09-01",
60+
"storageAccountName": "[parameters('baseName')]",
61+
"authorizationApiVersion": "2018-09-01-preview",
62+
"blobDataContributorRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe')]",
63+
"blobDataOwnerRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/b7e6dc6d-f1e8-4753-8033-0f276bb0955b')]",
64+
"encryption": {
65+
"services": {
66+
"file": {
67+
"enabled": true
68+
},
69+
"blob": {
70+
"enabled": true
71+
}
72+
},
73+
"keySource": "Microsoft.Storage"
74+
},
75+
"networkAcls": {
76+
"bypass": "AzureServices",
77+
"virtualNetworkRules": [],
78+
"ipRules": [],
79+
"defaultAction": "Allow"
80+
},
81+
"containerName": "documents"
5382
},
5483
"resources": [
84+
{
85+
"type": "Microsoft.Authorization/roleAssignments",
86+
"apiVersion": "[variables('authorizationApiVersion')]",
87+
"name": "[guid(concat('blobDataContributorRoleId', variables('storageAccountName')))]",
88+
"dependsOn": ["[variables('storageAccountName')]"],
89+
"properties": {
90+
"roleDefinitionId": "[variables('blobDataContributorRoleId')]",
91+
"principalId": "[parameters('testApplicationOid')]"
92+
}
93+
},
94+
{
95+
"type": "Microsoft.Authorization/roleAssignments",
96+
"apiVersion": "[variables('authorizationApiVersion')]",
97+
"name": "[guid(concat('blobDataOwnerRoleId', variables('storageAccountName')))]",
98+
"dependsOn": ["[variables('storageAccountName')]"],
99+
"properties": {
100+
"roleDefinitionId": "[variables('blobDataOwnerRoleId')]",
101+
"principalId": "[parameters('testApplicationOid')]"
102+
}
103+
},
55104
{
56105
"type": "Microsoft.CognitiveServices/accounts/providers/roleAssignments",
57-
"apiVersion": "2018-09-01-preview",
58-
"name": "[format('{0}/Microsoft.Authorization/{1}', variables('accountName'), guid(variables('accountName')))]",
106+
"apiVersion": "[variables('authorizationApiVersion')]",
107+
"name": "[format('{0}/Microsoft.Authorization/{1}', variables('cognitiveAccountName'), guid(variables('cognitiveAccountName')))]",
59108
"dependsOn": [
60-
"[resourceId('Microsoft.CognitiveServices/accounts', variables('accountName'))]"
109+
"[resourceId('Microsoft.CognitiveServices/accounts', variables('cognitiveAccountName'))]"
61110
],
62111
"properties": {
63112
"principalId": "[parameters('testApplicationOid')]",
64113
"roleDefinitionId": "[variables('taRoleId')]"
65114
}
66115
},
116+
{
117+
"type": "Microsoft.Storage/storageAccounts",
118+
"apiVersion": "[variables('storageApiVersion')]",
119+
"name": "[variables('storageAccountName')]",
120+
"location": "[parameters('location')]",
121+
"sku": {
122+
"name": "Standard_LRS",
123+
"tier": "Standard"
124+
},
125+
"kind": "StorageV2",
126+
"properties": {
127+
"networkAcls": "[variables('networkAcls')]",
128+
"supportsHttpsTrafficOnly": true,
129+
"encryption": "[variables('encryption')]",
130+
"accessTier": "Hot"
131+
},
132+
"resources": [
133+
{
134+
"name": "default",
135+
"type": "blobServices",
136+
"apiVersion": "[variables('storageApiVersion')]",
137+
"dependsOn": ["[variables('storageAccountName')]"],
138+
"properties": {
139+
"isVersioningEnabled": "[parameters('enableVersioning')]",
140+
"cors": {
141+
"corsRules": [
142+
{
143+
"allowedOrigins": ["*"],
144+
"allowedMethods": [
145+
"DELETE",
146+
"GET",
147+
"HEAD",
148+
"MERGE",
149+
"POST",
150+
"OPTIONS",
151+
"PUT",
152+
"PATCH"
153+
],
154+
"maxAgeInSeconds": 86400,
155+
"exposedHeaders": ["*"],
156+
"allowedHeaders": ["*"]
157+
}
158+
]
159+
},
160+
"lastAccessTimeTrackingPolicy": {
161+
"enable": true,
162+
"name": "AccessTimeTracking",
163+
"trackingGranularityInDays": 1,
164+
"blobType": ["blockBlob"]
165+
}
166+
},
167+
"resources": []
168+
},
169+
{
170+
"name": "default",
171+
"type": "fileServices",
172+
"apiVersion": "[variables('storageApiVersion')]",
173+
"dependsOn": ["[variables('storageAccountName')]"],
174+
"properties": {
175+
"cors": {
176+
"corsRules": [
177+
{
178+
"allowedOrigins": ["*"],
179+
"allowedMethods": ["DELETE", "GET", "HEAD", "MERGE", "POST", "OPTIONS", "PUT"],
180+
"maxAgeInSeconds": 86400,
181+
"exposedHeaders": ["*"],
182+
"allowedHeaders": ["*"]
183+
}
184+
]
185+
}
186+
},
187+
"resources": []
188+
}
189+
]
190+
},
191+
{
192+
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
193+
"apiVersion": "[variables('storageApiVersion')]",
194+
"name": "[format('{0}/default/{1}', variables('storageAccountName'), variables('containerName'))]",
195+
"dependsOn": [
196+
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
197+
]
198+
},
67199
{
68200
"type": "Microsoft.CognitiveServices/accounts",
69-
"name": "[variables('accountName')]",
70-
"apiVersion": "2017-04-18",
201+
"name": "[variables('cognitiveAccountName')]",
202+
"apiVersion": "[variables('cognitiveApiVersion')]",
71203
"sku": {
72204
"name": "S"
73205
},
74206
"kind": "TextAnalytics",
75207
"location": "[parameters('location')]",
208+
"dependsOn": [
209+
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
210+
],
76211
"properties": {
77-
"customSubDomainName": "[variables('accountName')]"
212+
"customSubDomainName": "[variables('cognitiveAccountName')]",
213+
"userOwnedStorage": [{
214+
"resourceId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
215+
}]
216+
},
217+
"identity": {
218+
"type": "SystemAssigned"
78219
}
79220
}
80221
],
@@ -93,15 +234,19 @@
93234
},
94235
"LANGUAGE_API_KEY": {
95236
"type": "string",
96-
"value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('accountName')), '2017-04-18').key1]"
237+
"value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('cognitiveAccountName')), variables('cognitiveApiVersion')).key1]"
97238
},
98239
"LANGUAGE_API_KEY_ALT": {
99240
"type": "string",
100-
"value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('accountName')), '2017-04-18').key2]"
241+
"value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', variables('cognitiveAccountName')), variables('cognitiveApiVersion')).key2]"
101242
},
102243
"ENDPOINT": {
103244
"type": "string",
104-
"value": "[concat('https://', variables('accountName'), parameters('cognitiveServicesEndpointSuffix'), '/')]"
245+
"value": "[concat('https://', variables('cognitiveAccountName'), parameters('cognitiveServicesEndpointSuffix'), '/')]"
246+
},
247+
"STORAGE_ACCOUNT_NAME": {
248+
"type": "string",
249+
"value": "[variables('storageAccountName')]"
105250
}
106251
}
107-
}
252+
}

0 commit comments

Comments
 (0)