I have an issue with my http trigger in azure functions. When I use the http trigger local the trigger is correctly getting the picture from the online azure storage container. Once azure function is deployed it no longer works.
Here is my code for the http trigger that work locally but not once deployed:
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Azure.Storage.Blobs;
namespace PlaygroundAzureFunctions
{
public static class HttpFromStorage
{
[FunctionName("GetSnapsnot")]
public static async Task<IActionResult> GetSnapsnot(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "Snapshot")] HttpRequest req,
ILogger log)
{
log.LogInformation($"Snapsnot requested at: {DateTime.Now}");
string Connection = Environment.GetEnvironmentVariable("AzureWebJobsStorage");
string containerName = Environment.GetEnvironmentVariable("ContainerName");
var blobClient = new BlobContainerClient(Connection, containerName);
var blob = blobClient.GetBlobClient("TestPicture.jpeg");
var image = await blob.OpenReadAsync();
log.LogInformation($"Snapsnot request returned at: {DateTime.Now}");
return new OkObjectResult(image);
}
}
}
Here is my local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "StringTakenFromCorrectStorageAccessKeysJustHiddenHere",
"ContainerName": "file-upload", // container name
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
I was aiming for once deployed i could use the public to the internet app and use its url to call the api to trigger that specific picture to be shown.
The errors in the function monitor is as follows:
