Пример #1
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Running analysis");
            var client           = new HttpClient();
            var moderationHelper = new ModerationHelper(client, key, region);
            var result           = await moderationHelper.ModerateText("Hello World");

            Console.WriteLine(result.ToString());
            Console.ReadKey();
        }
Пример #2
0
        public static async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
                                                     TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            string  requestBody    = new StreamReader(req.Body).ReadToEnd();
            dynamic data           = JsonConvert.DeserializeObject(requestBody);
            var     textToModerate = (string)data?.textToModerate;

            var moderationHelper    = new ModerationHelper(Client, "<your content moderation api key>", "<moderation service region>");
            ModerationResult result = await moderationHelper.ModerateText(textToModerate);

            return(data != null
                ? (ActionResult) new OkObjectResult(result.ToString())
                : new BadRequestObjectResult("Please pass a string to evaluate"));
        }