Ejemplo n.º 1
0
        public static async Task <SearchIndexerSkillset> CreateOrUpdateSkillSetAsync(SearchIndexerClient indexerClient, string skillSetName, IList <SearchIndexerSkill> skills, string cognitiveServicesKey)
        {
            SearchIndexerSkillset skillset = new SearchIndexerSkillset(skillSetName, skills)
            {
                Description = "skillsets",

                CognitiveServicesAccount = new CognitiveServicesAccountKey(cognitiveServicesKey)
            };

            // Create the skillset in your search service.
            // The skillset does not need to be deleted if it was already created
            // since we are using the CreateOrUpdate method
            try
            {
                await indexerClient.CreateOrUpdateSkillsetAsync(skillset);
            }
            catch (RequestFailedException ex)
            {
                Console.WriteLine("Failed to create the skillset\n Exception message: {0}\n", ex.Message);
                ExitProgram("Cannot continue without a skillset");
            }

            return(skillset);
        }