Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text Analytics ARM template for Live tests #7638

Merged
merged 13 commits into from
Feb 5, 2020
96 changes: 96 additions & 0 deletions sdk/textanalytics/test-resources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"baseName": {
"type": "string",
"defaultValue": "[resourceGroup().name]",
"metadata": {
"description": "The base resource name."
}
},
"endpointSuffix": {
"defaultValue": ".cognitiveservices.azure.com/",
"type": "String"
},
"testApplicationOid": {
"type": "String",
"metadata": {
"description": "The principal to assign the role to. This is application object id."
}
},
"tenantId": {
"type": "String",
"metadata": {
"description": "The tenant id to which the application and resources belong."
}
},
"testApplicationId": {
"type": "String",
"metadata": {
"description": "The application client id used to run tests."
}
},
"testApplicationSecret": {
"type": "String",
"metadata": {
"description": "The application client secret used to run tests."
}
}
},
"variables": {
"authorizationApiVersion": "2018-09-01-preview",
"textAnalyticsApiVersion": "2017-04-18",
"azureTextAnalyticsUrl": "[concat('https://', parameters('baseName'), parameters('endpointSuffix'))]",
"cognitiveServiceUserRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/a97b65f3-24c7-4388-baec-2e87135dc908')]"
},
"resources": [
{
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "[variables('authorizationApiVersion')]",
"name": "[guid(concat(variables('cognitiveServiceUserRoleId'), parameters('baseName')))]",
"dependsOn": [
"[parameters('baseName')]"
],
"properties": {
"principalId": "[parameters('testApplicationOid')]",
"roleDefinitionId": "[variables('cognitiveServiceUserRoleId')]"
}
},
{
"type": "Microsoft.CognitiveServices/accounts",
"name": "[parameters('baseName')]",
"apiVersion": "[variables('textAnalyticsApiVersion')]",
"sku": {
"name": "S"
},
"kind": "TextAnalytics",
"location": "[resourceGroup().location]",
"properties": {
"customSubDomainName": "[parameters('baseName')]"
}
}
],
"outputs": {
"AZURE_TENANT_ID": {
"type": "String",
"value": "[parameters('tenantId')]"
},
"AZURE_CLIENT_ID": {
"type": "String",
"value": "[parameters('testApplicationId')]"
},
"AZURE_CLIENT_SECRET": {
"type": "String",
"value": "[parameters('testApplicationSecret')]"
},
Comment on lines +75 to +86
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's continue to use the tests.yml to handle loading these, no need to output these here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the more recommended approach is to only maintain test variables in the tests-resources file as that can serve as a central place for all that info.
@danieljurek Can add more context.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of the variables being passed through the ARM template, this gives us one location to specify environment variables for a live test (compared with mixing environment variables defined in the ARM template and those defined in the tests.yml file).

Since the ARM template is meant to be used with New-TestResources.ps1 it is more convenient for contributors to specify the environment variables in one place. The script outputs the set of environment variables needed to run tests and doesn't require the contributor to know to consult the tests.yml file.

Either approach works but over time I've convinced myself that it makes sense to collect the environment variables in one place for the benefit of contributor experience.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of now, I have used test-resources.json to declare variables. Few other languages are also doing it. I think this is one think does not need to differ from other languages and have one common place for variables. So I will vote for keeping in this file.

"AZURE_TEXT_ANALYTICS_SUBSCRIPTION_KEY": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.CognitiveServices/accounts', parameters('baseName')), variables('textAnalyticsApiVersion')).key1]"
},
"AZURE_TEXT_ANALYTICS_ENDPOINT": {
"type": "string",
"value": "[variables('azureTextAnalyticsUrl')]"
}
}
}
4 changes: 0 additions & 4 deletions sdk/textanalytics/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@ jobs:
ServiceDirectory: textanalytics
EnvVars:
AZURE_TEST_MODE: RECORD
AZURE_CLIENT_ID: $(aad-azure-sdk-test-client-id)
AZURE_CLIENT_SECRET: $(aad-azure-sdk-test-client-secret)
AZURE_TENANT_ID: $(aad-azure-sdk-test-tenant-id)
AZURE_TEXT_ANALYTICS_ENDPOINT: $(java-textanalytics-sdk-endpoint)
AZURE_LOG_LEVEL: 3