惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
博客园_首页
W
WeLiveSecurity
S
Secure Thoughts
S
Security @ Cisco Blogs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hugging Face - Blog
Hugging Face - Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
H
Hacker News: Front Page
Project Zero
Project Zero
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Forbes - Security
Forbes - Security
T
Tor Project blog
I
Intezer
B
Blog
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
Schneier on Security
Schneier on Security
T
Threat Research - Cisco Blogs
AI
AI
Google DeepMind News
Google DeepMind News
L
LINUX DO - 最新话题
Cloudbric
Cloudbric
L
Lohrmann on Cybersecurity
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
Spread Privacy
Spread Privacy
Simon Willison's Weblog
Simon Willison's Weblog
罗磊的独立博客
Vercel News
Vercel News
A
Arctic Wolf
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
H
Heimdal Security Blog
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed

博客园 - 佛西亚

https访问 asp.net Core上传文件 .NET Framework 4.0 DLL注册GAC 使用iText 7读取PDF文件中的文本和图片 用SQL Server Profiler跟踪AX执行的SQL语句 D365升级包 Ant Design Pro V5 + Django Restful Framework Token认证前台实现 Ant Design Pro V5 + Django Restful Framework Token认证后台实现(二) Ant Design Pro V5 + Django Restful Framework Token认证后台实现(一) D365 FO产生随机字符串 D365 FO Array增加排序 D365 FO无法命中断点 Ant Design Pro V5 开发时使用后台服务数据 JavaScript跨域访问 同步数据库报错 DataEntity增加关联DataSource Java通过代理上传文件到Azure blob 使用iText7操作PDF D365 FO Json序列化和反序列化
D365 FO操作Azure Blob
佛西亚 · 2020-06-22 · via 博客园 - 佛西亚

 在AZure里,一般用Azure Blob做数据传输的中间媒介,D365 FO的数据生成到Blob里,其他系统从Blob里获取,或者相反,这样就不用单独设置FTP服务器了,当然这个是要钱的。
要想使用Blob,需要在AZure上创建存储账号,创建好存储账户以后,就可以设置访问密钥了。

 .NET提供了读写Azure里的类库,读写AZure Blob非常方便,访问只需要一个连接字符串做认证就可以了,用C#简单封装了一下访问的类库供D365 FO调用。

 1 public class AZureBlobHelper
 2     {
 3         CloudBlobContainer blobContainer;
 4         string path;
 5 
 6         public AZureBlobHelper(
 7             string _connectionString,
 8             string _containerName,
 9             string _path)
10         {            
11             blobContainer = CloudStorageAccount.Parse(_connectionString)
12                                                 .CreateCloudBlobClient()
13                                                 .GetContainerReference(_containerName);
14 
15             if (_path != string.Empty && _path.EndsWith("/") == false)
16             {
17                 path = _path + "/";
18             }
19             else
20             {
21                 path = _path;
22             }
23         }
24         public bool upload(MemoryStream _stream, string _fileName)
25         {            
26             CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(path + _fileName);
27             blockBlob.UploadFromStream(_stream, null, null, null);
28             return true;
29         }
30         
31         public string[] getFileList()
32         {
33             List<string> list = new List<string>();
34             CloudBlobDirectory direcotry =  blobContainer.GetDirectoryReference(path);
35             foreach(var file in direcotry.ListBlobs())
36             {
37                 string fileName = file.Uri.Segments[file.Uri.Segments.Length - 1];
38                 list.Add(fileName);
39             }
40             return list.ToArray();
41         }
42         public MemoryStream download(string _fileName)
43         {
44             MemoryStream ms = new MemoryStream();
45             CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(path + _fileName);            
46             blockBlob.DownloadToStream(ms);            
47             return ms;
48         }
49         public void delete(string _fileName)
50         {
51             CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(path + _fileName);
52             blockBlob.Delete();
53         }
54     }