目前最簡單的選擇是使用Azure的流按照您的計劃進行分析。但是,是的,您必須先將xml轉換爲json或其他支持的格式,然後才能使用數據。
其他選項更復雜,需要一些代碼和一種方法來託管代碼(例如使用工作者角色或Web作業),但卻提供了最大的靈活性。該選項是使用EventProcessor
從Event Hub讀取數據並將其放入數據庫中。
請參閱https://azure.microsoft.com/en-us/documentation/articles/event-hubs-csharp-ephcs-getstarted/瞭解如何設置。
主要工作是在Task IEventProcessor.ProcessEventsAsync(PartitionContext context, IEnumerable messages)
方法完成。基於這個例子,它會像這樣:
async Task IEventProcessor.ProcessEventsAsync(PartitionContext context, IEnumerable<EventData> messages)
{
foreach (EventData eventData in messages)
{
string xmlData = Encoding.UTF8.GetString(eventData.GetBytes());
// Parse the xml and store the data in db using Ado.Net or whatever you're comfortable with
}
//Call checkpoint every 5 minutes, so that worker can resume processing from 5 minutes back if it restarts.
if (this.checkpointStopWatch.Elapsed > TimeSpan.FromMinutes(5))
{
await context.CheckpointAsync();
this.checkpointStopWatch.Restart();
}
}
我的數據庫位於雲中的虛擬機上。 Azure流分析僅將其移至天青SQLdb,而不是位於雲中的虛擬機中。 – Aparna