Пример #1
0
        public HttpResponseMessage Prompt([FromBody] PromptRequestModel data)
        {
            // Would be a service call
            string result = ProcessPrompt(data);

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Пример #2
0
        private string ProcessPrompt(PromptRequestModel data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            return($"You wrote : {data.Data}");
        }
Пример #3
0
        public async Task <HttpResponseMessage> WriteBlobAsync([FromBody] PromptRequestModel data)
        {
            if (ModelState.IsValid)
            {
                // Would be a service call
                await WriteBlobImplementationAsync(data);

                return(Request.CreateResponse(HttpStatusCode.OK));
            }

            return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid body"));
        }
Пример #4
0
        private async Task WriteBlobImplementationAsync(PromptRequestModel data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            // Setup config and create container
            string cs = ConfigurationManager.ConnectionStrings["BlobStorageAccount"].ConnectionString;
            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(cs);
            CloudBlobClient     cloudBlobClient     = cloudStorageAccount.CreateCloudBlobClient();
            CloudBlobContainer  logContainer        = cloudBlobClient.GetContainerReference("appinsightspres");
            await logContainer.CreateIfNotExistsAsync();

            // Upload the blob
            string         blobName  = Guid.NewGuid().ToString();
            CloudBlockBlob blockBlob = logContainer.GetBlockBlobReference(blobName);
            await blockBlob.UploadTextAsync(data.Data);
        }