Skip to content

Instantly share code, notes, and snippets.

@shinkathe
Last active June 17, 2022 07:14
Show Gist options
  • Save shinkathe/dc437944c795a483fbf6475e385f49ee to your computer and use it in GitHub Desktop.
Save shinkathe/dc437944c795a483fbf6475e385f49ee to your computer and use it in GitHub Desktop.
// ##### READ EVENT GRID EVENT FROM REQUEST #####
log.LogInformation("Begin handling request. {EventGridEvent}", eventGridEvent.Data);
if (!TryGetEventData<string>(eventGridEvent, CREATED_EVENT_URL, out var url))
{
log.LogError("EventData could not be parsed. UrlFound check failed.");
return;
}
// ##### READ FILE NAME AND STORAGE ACCOUNT CONTAINER NAME FROM EVENT GRID EVENT
if (!TryGetFileNameAndContainerFromUrl(url, out var fileName, out var container))
{
log.LogError("Invalid file URI, could not process. Url value: {Url}", url);
return;
}
// ##### DOWNLOAD FILE FROM AZURE STORAGE #####
log.LogInformation("Downloading {FileName} from container {Container}...", fileName, container);
var blobClient = new BlobClient(ConnectionString, container, fileName);
// ##### DOWNLOAD FILE #####
using var ms = new MemoryStream();
await blobClient.DownloadToAsync(ms);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment