我是一个有经验的窗口C#开发,但新Azure的世界,所以试图找出一个“最佳实践”为我实现一个或多个Azure的云服务。Azure文件系统 - 我可以“观察”还是只能轮询?
我有一些可以将文件保存到文件夹(或可能是一组文件夹)的(外部和我的控制之外的)源。在我的Windows系统下的当前状态,我有一个FileSystemWatcher的建立是为了监测一个文件夹,引发事件时,文件出现在那里。
在Azure中的世界,什么是等价的方式来做到这一点?或者在那里?
我知道我可以创建一个计时器(或睡眠)来传递一些时间(比如30秒),并轮询文件夹,但我不确定这是云环境中的“最佳”方式。
重要的是要注意,我无法控制输入 - 换句话说,文件是由我无法控制的外部设备保存的;所以我不能,例如,当文件被保存时将消息推送到队列中,并且对该消息作出响应...
尽管最终这就是目标......所以我打算有一个“观察者”的服务,这将(经由事件或轮询)检测的一个或多个文件的存在,并按下一个消息到适当的队列用于我的工作流,以响应下一个步骤。
应该指出,我使用VS2015和最新的Azure SDK的东西,所以我不受任何传统的限制。
我有什么到目前为止基本上是这样(一个更大的代码库的片段):
storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
// Create a CloudFileClient object for credentialed access to File storage.
fileClient = storageAccount.CreateCloudFileClient();
// Obtain the file share name from the config file
string sharenameString = CloudConfigurationManager.GetSetting("NLRB.Scanning.FileSharename");
// Get a reference to the file share.
share = fileClient.GetShareReference(sharenameString);
// Ensure that the share exists.
if (share.Exists())
{
Trace.WriteLine("Share exists.");
// Get a reference to the root directory for the share.
rootDir = share.GetRootDirectoryReference();
//Here is where I want to start watching the folder represented by rootDir...
}
在此先感谢。
听起来不错,我正在使用Azure文件服务(或...试图...) –
我已经添加了一个代码片段到我原来的问题,所以希望你(或其他人)可以提供更具体的指导如何做我想做的事情。谢谢! –