3
votes

I have to assign the subscription key to luis app which i created on azure.

I am using LUIS Api V2.0 to Assign Subscription Key To App.

I have used Update application version external key endpoint for it. https://westus.api.cognitive.microsoft.com/luis/api/v2.0/apps/{appId}/versions/{versionId}/externalKeys

(API sample url) https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5890b47c39e2bb052c5b9c43/console

I have created the new LUIS subscription key from azure. However, I am not able to assign the subscription key to my app.

Below is my body request

{
    "type": "LanguageUnderstanding",
    "value": "ee29*******************717"
}

below is the response which i got.

{
  "error": {
    "code": "BadArgument",
    "message": "Invalid external key type"
  }
}

I have modified the type variable in my request body like, Cognitive Service

  • CognitiveService
  • Cognitive Services
  • CognitiveServices Language
  • Understanding Intelligent Service
  • LanguageUnderstandingIntelligentService
  • LanguageUnderstanding
  • Language Understanding

But, none of them seems working for me. I am getting the same error response every time.


Further, I have googled around and found that this is possible with LUIS Api V1.0 . So, I tried with Assign Subscription Key To App

( API sample url ) https://westus.dev.cognitive.microsoft.com/docs/services/56d95961e597ed0f04b76e58/operations/580c6eea39e2bb161819981d/console

following is my endpoint https://westus.api.cognitive.microsoft.com/luis/v1.0/prog/apps/5b2556b8-f97d-4772-9bf0-4f576ec9fc59/subscription

Request body

08ebb******************e7142d3

Request Header

{ "Content-Type" : "text/plain", "Ocp-Apim-Subscription-Key":"as23d*******123d"}

Error Response

{
  "Message": "The request entity's media type 'text/plain' is not supported for this resource."
}

I even tried with content-type:application/json. but , it too was not working.

So. I am not able to assign the subscription key by using either V1.0 or V2.0 LUIS api

Please guide me how assign newly created subscription key to luis with api.

I have also tried the following V2.0 endpoint requests, but they are deprecated now. Assign subscription key to version , Add external api key, Add subscription key

2

2 Answers

2
votes

You can use a new endpoint which allows you to add keys programmatically - endpoint

To use it you need:

  1. Get an Azure Resource Manager token from this link. This token does expire so use it immediately. The request returns an Azure Resource Manager token. Or you can use Azure CLI:

    az account get-access-token --query accessToken -o tsv

  2. Assign the token to the LUIS resource with the endpoint

This POST API requires the following settings:

Header: Authorization - The value of Authorization is Bearer {token}. (Notice that the token value must be preceded by the word Bearer and a space.)

Header: Ocp-Apim-Subscription-Key - Your authoring key.

Header: Content-type - application/json Query string: appid - The LUIS app ID.

Body :

{"AzureSubscriptionId":"ddda2925-af7f-4b05-9ba1-2155c5fe8a8e",
"ResourceGroup": "resourcegroup-2",
"AccountName": "luis-uswest-S0-2"}

When this API is successful, it returns a 201 - created status.

Docs

1
votes

The documentation which you are referring to is for the old version(v1). Assigning subscription key through Programmatic API has been deprecated as mentioned here.

Azure Endpoint Keys are now automatically provided based on which Tenant ID and Subscription Name you select when choosing the key in your LUIS application’s “Publish app” page. Users are no longer required to copy "Keys from Azure" and then manually add them to their LUIS accounts. The link I provided you earlier that leads to “Manage your keys” provides a walkthrough process of how to assign a key to your app. 

If you have any other concerns for LUIS support, please contact [email protected].