Forum Discussion

gerhardtm's avatar
gerhardtm
Copper Contributor
Oct 18, 2023

Azure Search Custom Skill API Invalid Response

I'm implementing an Azure Cognitive Search Skillset and I'm at my wits end with this issue:

The only skill I currently have in the skillset is a custom skill that calls an app function.

The app function is defined as follows:

 

        [FunctionName("TestFunction")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            object result = new
            {
                Values = new List<object>()
                {
                    new
                    {
                        RecordId = "b5",
                        Data = new
                        {
                            ContractDate = new 
                            {
                                Day = 5,
                                Month = 2,
                                Year = 2018
                            }
                        }
                    },
                    new
                    {
                        RecordId = "ai",
                        Data = new
                        {
                            ContractDate = new
                            {
                                Day = 3,
                                Month = 11,
                                Year = 2017
                            }
                        }
                    },
                    new
                    {
                        RecordId = "c3",
                        Data = new { },
                        Errors = new List<object>()
                        {
                            new 
                            {
                                Message = "contractText field required "
                            }
                        },
                        Warnings = new List<object>()
                        {
                            new
                            {
                                Message = "Date not found"
                            }
                        }
                    }
                }
            };

            return new OkObjectResult(result);
        }
    }

 

 

The skillset is defined as:

 

{
  "@odata.context": "https://<ommitted>.search.windows.net/$metadata#skillsets/$entity",
  "@odata.etag": "\"0x8DBCF46B8B13B2B\"",
  "name": "testskillset",
  "description": "Skillset for testing purposes",
  "skills": [
    {
      "@odata.type": "#Microsoft.Skills.Custom.WebApiSkill",
      "name": "custom_skill_1",
      "description": "",
      "context": "/document",
      "uri": "https://<ommitted>.azurewebsites.net/api/TestFunction?code=<ommitted>",
      "httpMethod": "POST",
      "timeout": "PT30S",
      "batchSize": 1000,
      "degreeOfParallelism": null,
      "inputs": [
        {
          "name": "file_url",
          "source": "/document/file_data/url"
        }
      ],
      "outputs": [
        {
          "name": "customapiresult",
          "targetName": "custom_api_result"
        }
      ],
      "httpHeaders": {}
    }
  ],
  "cognitiveServices": {
    "@odata.type": "#Microsoft.Azure.Search.DefaultCognitiveServices",
    "description": null
  },
  "knowledgeStore": null,
  "encryptionKey": null
}

 


When I publish the function to Azure and call it from Postman, it works as expected and returns the following result:



That result fits the format requirement for a custom skill exactly according to this article.

Unfortunately, when I run the skillset in a cognitive search debug session, I get the following error:


All three records that are returned, have id's so I have no clue what the problem is.

Thanks in advance.




No RepliesBe the first to reply

Share

Resources