Creation of Cognitive Services for Language from an ARM template not working

Xavier 31 Reputation points
2022-06-16T13:00:47.57+00:00

We are creating our Azure Cognitive services from an ARM template.

The template creates both a Cognitive Service for Language and a Cognitive Search Service, this is the template:

azure.json:

{  
        "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",  
        "contentVersion": "1.0.0.0",  
        "parameters": {  
            // Global Parameters  
            "projectPrefix": {  
                "type": "string"  
            },  
            "componentGroup": {  
                "type": "string"  
            },  
            // Azure Search Service settings  
            "searchHostingMode": {  
                "type": "string",  
                "defaultValue": "default",  
                "allowedValues": [  
                    "default",  
                    "highDensity"  
                ],  
                "metadata": {  
                    "description": "Applicable only for SKU set to standard3. You can set this property to enable a single, high density partition that allows up to 1000 indexes, which is much higher than the maximum indexes allowed for any other SKU."  
                }  
            },  
            "searchSKU": {  
                "type": "string",  
                "defaultValue": "basic",  
                "allowedValues": [  
                    "free",  
                    "basic",  
                    "standard",  
                    "standard2",  
                    "standard3"  
                ],  
                "metadata": {  
                    "description": "The SKU of the search service you want to create. E.g. free or standard"  
                }  
            },  
            "searchPartitionCount": {  
                "type": "int",  
                "allowedValues": [  
                    1,  
                    2,  
                    3,  
                    4,  
                    6,  
                    12  
                ],  
                "defaultValue": 1,  
                "metadata": {  
                    "description": "Partitions allow for scaling of document count as well as faster indexing by sharding your index over multiple Azure Search units."  
                }  
            },  
            "searchReplicaCount": {  
                "type": "int",  
                "minValue": 1,  
                "maxValue": 12,  
                "defaultValue": 1,  
                "metadata": {  
                    "description": "Replicas distribute search workloads across the service. You need 2 or more to support high availability (applies to Basic and Standard only)."  
                }  
            },  
            // Azure Cognitive Services for Language  
            "languageSKU":{  
                "defaultValue": "s",  
                "type": "string",  
                "allowedValues": [  
                    "f", // free  
                    "s"  // standard  
                ]  
            }  
        },  
        "functions": [  
         {  
          "namespace": "stringUtils",  
          "members": {  
            "buildServiceName": {  
              "parameters": [  
                {  
                  "name": "resourceName",  
                  "type": "string"  
                },  
                {  
                  "name": "sku",  
                  "type": "string"  
                },  
                {  
                  "name": "resourceType",  
                  "type": "string"  
                }  
              ],  
              "output": {  
                "type": "string",  
                "value": "[concat(  
                  parameters('resourceName'), '-',   
                  parameters('sku'), '-',  
                  parameters('resourceType')  
                )]"  
              }  
            }  
          }  
        }  
        ],  
        "variables": {  
            "languageAzureSearchName": "[stringUtils.buildServiceName(parameters('projectPrefix'), parameters('searchSKU'), 'language-search')]",  
            "languageServiceName": "[stringUtils.buildServiceName(parameters('projectPrefix'), parameters('languageSKU'), 'language-service')]"  
        },  
        "resources": [  
            {  
                "comments": "All Cognitive Services for Language will use a single Azure Search Service",  
                "type": "Microsoft.Search/searchServices",  
                "apiVersion": "2021-04-01-preview",  
                "name": "[variables('languageAzureSearchName')]",  
                "location": "[resourceGroup().location]",  
                "tags": {  
                    "componentGroup": "[parameters('componentGroup')]"  
                },  
                "sku": {  
                    "name": "[parameters('searchSKU')]"  
                },  
                "properties": {  
                    "replicaCount": "[parameters('searchReplicaCount')]",  
                    "partitionCount": "[parameters('searchPartitionCount')]",  
                    "hostingMode": "[parameters('searchHostingMode')]",  
                    "disabledDataExfiltrationOptions": [],  
                    "semanticSearch": "disabled"  
                }  
            },  
            // Cognitive Services for Language  
            {  
                "type": "Microsoft.CognitiveServices/accounts",  
                "apiVersion": "2022-03-01",  
                "name": "[variables('languageServiceName')]",  
                "location": "[resourceGroup().location]",  
                "tags": {  
                    "componentGroup": "[parameters('componentGroup')]"  
                },  
                "dependsOn": [  
                    "[resourceId('Microsoft.Search/searchServices', variables('languageAzureSearchName'))]"  
                ],  
                "sku": {  
                    "name": "[parameters('languageSKU')]"  
                },  
                "kind": "TextAnalytics",  
                "identity": {  
                    "type": "SystemAssigned"  
                },  
                "properties": {  
                    "apiProperties": {  
                        "qnaAzureSearchEndpointId": "[resourceId('Microsoft.Search/searchServices', variables('languageAzureSearchName'))]"  
                    },  
                    "customSubDomainName": "[variables('languageServiceName')]"  
                }  
            }  
        ]  
    }  

and the parameters:

azure.parameters.json

{  
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",  
    "contentVersion": "1.0.0.0",  
    "parameters": {  
        "projectPrefix": {  
            "value": "myProject"  
        },  
        "componentGroup": {  
            "value": "myComponentGroup"   
        },  
        "searchHostingMode": {  
            "value": "default"  
        },  
        "searchSKU": {  
            "value": "basic"  
        },  
        "searchPartitionCount": {  
            "value": 1  
        },  
        "searchReplicaCount": {  
            "value": 1  
        },  
        "languageSKU": {  
            "value": "s"  
        }  
    }  
}  

The resources are created from the 'az cli':

az deployment group create --resource-group myResourceGroup --template-file ./azure.json --parameters ./azure.parameters.json --subscription mySubscription -c  

Everything is created with no issues, and we can see this in Azure Portal:

212116-screen-shot-2022-06-16-at-150538.png

Buttttttt... when attempting to switch to this resource from Language Studio or trying to create a new project there, we receive this error:

{  
  "error": {  
    "code": "AzureCognitiveSearchNotFound",  
    "message": "Please attach an azure cognitive search service to your Text Analytics resource to use the custom Question Answering skill."  
  }  
}  

We found a couple ugly work-rounds:

  1. if we switch to another Search Service and then we switch back to the one created it works.
  2. If we click on "Sync keys linked to the selected Azure Cognitive Search service." and we apply it works.

Looks like some kind of bug when creating the resources from ARM templates, or maybe we are missing something.

We have compared the fixed exported ARM templates versus the applied ones and they are the same....

Thanks,
Xavi

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
821 questions
Azure AI Language
Azure AI Language
An Azure service that provides natural language capabilities including sentiment analysis, entity extraction, and automated question answering.
379 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,559 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Xavier 31 Reputation points
    2022-06-17T10:13:11.74+00:00

    I've found the issue.

    The Properties of the '"type": "Microsoft.CognitiveServices/accounts"' resource missed the 'qnaAzureSearchEndpointKey':

    "properties": {  
                    "apiProperties": {  
                        "qnaAzureSearchEndpointId": "[resourceId('Microsoft.Search/searchServices', variables('languageAzureSearchName'))]",  
                        "qnaAzureSearchEndpointKey": "[listAdminKeys(resourceId('Microsoft.Search/searchServices/', variables('languageAzureSearchName')), '2021-04-01-preview').primaryKey]"  
                    },  
                    "customSubDomainName": "[variables('languageServiceName')]"  
                }  
    

    It would be nice that an error is raised at creation time asking for the MANDATORY missing parameter...

    5 people found this answer helpful.