Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Created November 29, 2019 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinyoo/977295c0919f5e4fcd7a7eebc4455a27 to your computer and use it in GitHub Desktop.
Save justinyoo/977295c0919f5e4fcd7a7eebc4455a27 to your computer and use it in GitHub Desktop.
25 Days of Serverless
[FunctionName(nameof(GiftPhotoValidationFunction))]
public static async Task Run([BlobTrigger(_containerName)] CloudBlockBlob blockBlob, ILogger log)
{
log.LogInformation("Validating Gift Image is a PNG");
if (blockBlob.Name.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase))
{
log.LogInformation("Confirmed PNG");
}
else
{
log.LogInformation($"Photo {blockBlob.Name} is not a PNG");
log.LogInformation($"Deleting {blockBlob.Name} from container");
await blockBlob.DeleteAsync().ConfigureAwait(false);
log.LogInformation($"Deleted {blockBlob.Name}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment