D365: Azure Blob Storage(二)认证访问
D365可以通过如下三种方式认证访问Azure Blob Storage
方式1,通过连接字符串认证访问,代码参考如下,连接字符串可以在Storage account的access key页签里面找到
storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount::Parse("***************************");
cloudBlobClient = storageAccount.CreateCloudBlobClient();
cloudBlobContainer = cloudBlobClient.GetContainerReference("test6666");
方式2,用Storage account和access key,代码参考如下,account和key可以在Storage account的access key里面找到
storageCredentials = new Auth.StorageCredentials("*************","*********************************");
storageAccount = new CloudStorageAccount(storageCredentials, true);
cloudBlobClient = storageAccount.CreateCloudBlobClient();
cloudBlobContainer = cloudBlobClient.GetContainerReference("test6666");
方式3,通过sos token和URL认证访问,sos token在Storage accont的shared access signature页签下进行配置,URL地址https://blobstoragetest888.blob.core.windows.net,把其中的blobstoragetest888替换自己的storage account name即可
storageCredentials = new Auth.StorageCredentials("sos token");
cloudBlobClient = new CloudBlobClient(new System.Uri("url"), storageCredentials);
cloudBlobContainer = cloudBlobClient.GetContainerReference("test6666");