public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            string name = req.Query["name"];

            if (name == null)
            {
                return(new NotFoundResult());
            }

            log.LogInformation($"Blob to load {name}");
            SmsSentConfirmation confirmation = await DownloadSmsSentConfirmation(name);

            if (confirmation == null)
            {
                return(new NotFoundResult());
            }

            log.LogInformation($"Downloaded: {confirmation}");

            return(new OkObjectResult(confirmation));
        }
Beispiel #2
0
        public static async Task <string> Run([BlobTrigger("greeting-requests/{name}")] CloudBlockBlob blob, string name, ILogger log)
        {
            log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name}");

            log.LogInformation("Metadata");
            log.LogInformation($"- Name: {blob.Name}");
            log.LogInformation($"- StorageUri: {blob.StorageUri}");
            log.LogInformation($"- Container: {blob.Container.Name}");

            var greetingRequest = await DownloadGreetingRequest(blob);

            log.LogInformation($"- Downloaded: {greetingRequest}");

            string sendReceiptId = SendSms(greetingRequest);

            var confirmation = new SmsSentConfirmation
            {
                ReceiptId = sendReceiptId,
                Message   = greetingRequest.Message,
                Number    = greetingRequest.Number
            };

            return(JsonConvert.SerializeObject(confirmation));
        }