When using an SSIS Script task to talk to Azure Blob storage, the following code does not run, it builds ok and will run in a console app! Can anyone provide any insight into what's going wrong, as there are no error messages other than this one within SSIS or the event logs.
Namespaces:
using System;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
using System.Linq;
Code:
string AccountName = Dts.Variables["User::AccountName"].Value.ToString();
string AccountKey = Dts.Variables["User::AccountKey"].Value.ToString();
try
{
StorageCredentials storageCredentials = new StorageCredentials(AccountName, AccountKey);
CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(storageCredentials, useHttps: true);
CloudBlobClient BlobClient = cloudStorageAccount.CreateCloudBlobClient();
CloudBlobContainer Container = BlobClient.GetContainerReference("deltapocstorage");
CloudBlobDirectory blobDirectory = Container.GetDirectoryReference("instance1/");
CloudBlockBlob latestBlob = blobDirectory.ListBlobs()
.OfType<CloudBlockBlob>()
.OrderByDescending(m => m.Properties.LastModified)
.ToList()
.FirstOrDefault();
DateTimeOffset lastModifiedDate = new DateTimeOffset();
if (latestBlob != null)
{
lastModifiedDate = latestBlob.Properties.LastModified.GetValueOrDefault();
Dts.Variables["User::MostRecentRecord"].Value = lastModifiedDate.AddMilliseconds(1).ToString("dd/MM/yyyy HH:mm:ss.fff");
}
Dts.TaskResult = (int)ScriptResults.Success;
}
catch
{
Dts.TaskResult = (int)ScriptResults.Failure;
}
Any ideas would be appreciated,
regards, Anthony