Reputation: 141
I'm working on a SSIS project using SSDT (Sql Server Data Tools) with Visual Studio 2015 and I'm referencing the dll Microsoft.WindowsAzure.Storage.dll in a Script Task and using C# on my project but it keeps throwing the following message:
Could not load file or assembly 'Microsoft.WindowsAzure.Storage, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I have already tried to Unblock the DLL using Windows PowerShell, registering the dll on Windows, checked if I had copied the dll into bin directory on my project folder, but no results at all.
public void Main()
{
// TODO: Add your code here
string srcBlob = (string) Dts.Variables["User::dBlobName"].Value;
// Substitui o nome da pasta PROCESSAR para PROCESSADOS
string destBlobName = srcBlob.Replace((string)Dts.Variables["$Project::dSrcBlobDirectory"].Value, (string)Dts.Variables["$Project::dDestBlobDirectory"].Value);
string srcContainerName = (string)Dts.Variables["$Project::dBlobContainer"].Value;
string accountName = (string)Dts.Variables["$Project::dStorageAccountName"].Value;
//byte[] storageAccessKey = Encoding.ASCII.GetBytes((string) Dts.Variables["$Project::dStorageAccessKey"].Value);
string storageAccessKey = (string)Dts.Variables["$Project::dStorageAccessKey"].Value;
MoveBlobInSameStorageAccount(accountName, storageAccessKey, srcContainerName, srcBlob, destBlobName);
Dts.TaskResult = (int)ScriptResults.Success;
}
static void MoveBlobInSameStorageAccount(string accountName, string accountKey, string containerName, string sourceBlobName, string destBlobName)
{
var cred = new StorageCredentials(accountName, accountKey);
var account = new CloudStorageAccount(cred, true);
var client = account.CreateCloudBlobClient();
var sourceContainer = client.GetContainerReference(containerName);
var sourceBlob = sourceContainer.GetBlockBlobReference(sourceBlobName);
var destinationContainer = client.GetContainerReference(containerName);
var destinationBlob = destinationContainer.GetBlockBlobReference(destBlobName);
destinationBlob.StartCopy(sourceBlob);
sourceBlob.Delete(DeleteSnapshotsOption.IncludeSnapshots);
}
Could you help?
Upvotes: 2
Views: 3979
Reputation: 419
You can add dlls (including Microsoft.WindowsAzure.Storage.dll) to the Azure SSIS runtime, as explained here: https://learn.microsoft.com/en-us/azure/data-factory/how-to-configure-azure-ssis-ir-custom-setup
Thank you Geri for doing the research: Script task to upload zip file to blob storage with azure datafactory SSIS
Upvotes: 0
Reputation: 18465
I used the HttpClient
to invoke the Blob Storage REST API before. Based on your description, you are using Microsoft Azure Storage Client Library for .NET, I assumed that the assembly could not load correctly, since it is not in the GAC. You may need to leverage an AppDomain.AssemblyResolve event handler for loading the assembly, more detailed tutorial, you could refer to How to load an Assembly in a SSIS script task that isn’t in the GAC.
Upvotes: 3