Hi All,
I am trying to connect with azure file share and getting 403 forbidden error "Remote server returned error" at line ( if (fileShare.Exists(null, null)))
Please let me know what would be the blocker here?
Also would like to know should I have to PASS the SAS token or the account key along with the storage account name to authenticate the request. Please confirm this
Below is my code . Please let me know If I am doing the right thing...
using Microsoft.Azure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.File;
public class WTL_6DeeAzureBlobService
{
#File
#define.delimiterField(',')
public static boolean establishCloudConnection()
{
#OCCRetryCount;
System.IO.MemoryStream memoryStream;
System.String storageAccountName;
System.String keyValue;
CloudStorageAccount storageAccount;
CloudFileClient fileClient;
CloudFileShare fileShare;
CloudFileDirectory fileDirectoryRoot;
CloudFileDirectory fileDirectory;
CloudFile file;
TextStreamIo textStreamIo;
Counter counter;
container rec;
storageAccountName = "stcpd6dstgtstwe01";
keyValue = WTL_APIStringBase64Converter.Base64Encoder::Base64Encoding("");
var storageCredentials = new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(storageAccountName, keyValue);
storageAccount = new Microsoft.WindowsAzure.Storage.CloudStorageAccount(storageCredentials, true);
fileClient = storageAccount.CreateCloudFileClient();
fileShare = fileClient.GetShareReference('azfile6dappsmb01');
if (fileShare.Exists(null, null))
{
fileDirectoryRoot = fileShare.GetRootDirectoryReference();
fileDirectory = fileDirectoryRoot.GetDirectoryReference("");
if (fileDirectory.Exists(null, null))
{
file = fileDirectory.GetFileReference('File.csv');
if (file.Exists(null, null))
{
memoryStream = new System.IO.MemoryStream();
file.DownloadToStream(memoryStream, null, null, null);
textStreamIo = TextStreamIo::constructForRead(memoryStream);
try
{
if (textStreamIo)
{
if (textStreamIo.status())
{
throw Global::error("@SYS52680");
}
textStreamIo.inFieldDelimiter(#delimiterField);
textStreamIo.inRecordDelimiter(#delimiterCRLF);
counter = 0;
while (!textStreamIo.status())
{
rec = textStreamIo.read();
if (conLen(rec))
{
//vendABN = conPeek(rec, 1);
//info(strFmt("%1", vendABN));
}
}
}
}
catch (Exception::Error)
{
error("An error occured. Please contact your system administrator.");
}
}
}
}
return true;
}
public static boolean readFile(CloudBlobContainer _cloudBlobCon)
{
return true;
}
public static boolean archiveFile()
{
return true;
}
}