private static async Task SendCompleteNotification(Message message, string uri) { var hubConnection = new HubConnection(url); hub = hubConnection.CreateHubProxy("GifServerHub"); await hubConnection.Start(); Console.WriteLine("Invoked GifGenerationCompleted with URL: {0}", uri); await hub.Invoke("GifGenerationCompleted", message.HubId, uri); hubConnection.Stop(); }
private static string SetMetadataAndCleanup(Message message) { // instance clients var storageClientAccount = Microsoft.WindowsAzure.CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["AzureJobsData"].ConnectionString); var blobClient = new Microsoft.WindowsAzure.StorageClient.CloudBlobClient(storageClientAccount.BlobEndpoint, storageClientAccount.Credentials); var storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["AzureJobsData"].ConnectionString); var tableClient = new Microsoft.WindowsAzure.Storage.Table.CloudTableClient(storageAccount.TableEndpoint, storageAccount.Credentials); // get output blob uri var blobUri = blobClient.GetContainerReference("memes").GetBlockBlobReference(message.BlobName).Uri.AbsoluteUri; // save metadata var table = tableClient.GetTableReference("MemeMetadata"); table.CreateIfNotExists(); var requestOptions = new Microsoft.WindowsAzure.Storage.Table.TableRequestOptions() { RetryPolicy = new Microsoft.WindowsAzure.Storage.RetryPolicies.LinearRetry(TimeSpan.FromMilliseconds(500), 5) }; table.Execute(Microsoft.WindowsAzure.Storage.Table.TableOperation.Insert(new MemeMetadata(message.BlobName, blobUri, message.OverlayText, message.UserName)), requestOptions); try { // delete source var container = blobClient.GetContainerReference("uploads"); var blob = container.GetBlockBlobReference(message.BlobName); blob.Delete(); } catch (Exception ex) { Console.WriteLine("WARNING! deleting blob: " + ex.Message); } return blobUri; }