Skip to content

Commit

Permalink
Cleaning up function
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Hall (DEVDIV) committed Dec 4, 2018
1 parent f06230a commit 60b51cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using System;
using System.IO;
using System.Threading.Tasks;
using ImageGallery.Model;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;

Expand All @@ -17,7 +18,7 @@ public static class DeleteOriginalImage
public static async Task Run([BlobTrigger(Config.WatermarkedContainer + "/{name}",
Connection = "AzureWebJobsStorage")]Stream myBlob,
string name,
TraceWriter log)
ILogger log)
{
string connectionString = Environment.GetEnvironmentVariable("AzureWebJobsStorage", EnvironmentVariableTarget.Process);
CloudStorageAccount account = CloudStorageAccount.Parse(connectionString);
Expand All @@ -28,6 +29,8 @@ public static async Task Run([BlobTrigger(Config.WatermarkedContainer + "/{name}
CloudBlockBlob blockBlob = container.GetBlockBlobReference(name);

await blockBlob.DeleteIfExistsAsync();

log.LogInformation("Deleted original: {0}", name);
}
}
}
9 changes: 5 additions & 4 deletions CoreImageGallery/ImageGallery.AzFunctions/ImageUploaded.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System;
using System;
using System.IO;
using ImageGallery.Model;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace Watermarker
{
Expand All @@ -14,16 +15,16 @@ public static class ImageUploaded
public static void Run([BlobTrigger("images/{name}")]Stream inputBlob,
[Blob("images-watermarked/{name}", FileAccess.Write)] Stream outputBlob,
string name,
TraceWriter log)
ILogger log)
{
try
{
WaterMarker.WriteWatermark(WaterMarkText, inputBlob, outputBlob);
log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {inputBlob.Length} Bytes");
log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {inputBlob.Length} Bytes");
}
catch (Exception e)
{
log.Error($"Watermaking failed {e.Message}");
log.LogError($"Watermaking failed {e.Message}");
}
}
}
Expand Down
31 changes: 0 additions & 31 deletions CoreImageGallery/ImageGallery.AzFunctions/ImageUploaded.txt

This file was deleted.

0 comments on commit 60b51cb

Please sign in to comment.