[Azure]設定 Azure Stream Analytics Job 中儲存參考的 TimeFormat 為 HH-mm

  • 1699
  • 0
  • IOT
  • 2016-03-05

最近手動設定 Remote Monitoring System 的 Azure Stream Analytics Job 後發現,

當 Device 送來的溫度高於設定的Rule時,那個 Azure Stream Analytics Job 的輸出都是 0。

怎麼會這樣呢?

環境: Azure Stream Analytics Job, Storage

查看 Storage 中的存放格式為 yyyy-MM-dd/HH:mm,如下,

而在 Azure Stream Analytics Job 的時間格式卻只選得到 HH ,如下,

那怎麼辦呢?

這時只好透過 PowerShell 來解決,

先將原本的 Azure Stream Analytics Job 停止。

登入Azure

Login-AzureRMAccount

先看一下目前 Stream Analytics Job 的狀況,

get-azurermstreamanalyticsjob -resourcegroupname 你的resourceGroupName -name 你的JobName

get-azurermstreamanalyticsinput -resourcegroupname 你的resourceGroupName -jobname 你的JobName -name 要修改的inputName

將要更新的 Input 存成一個 json 檔,類似如下,

{
   "Name": "DeviceRulesBlob",
   "Properties": {
     "DataSource": {
       "Properties": {
         "Container": "devicerules",
         "DateFormat": "yyyy-MM-dd",
         "PathPattern": "{date}/{time}/devicerules.json",
         "StorageAccounts": [
           {
             "AccountKey": "YtfTB5yj51dFtehcW9hS54enjV36Wj6rsX8ZuiF5HD/0FpCH+XuMGTmxpKc8WCuzAqqp1UDH/wZLagJUJSDH1w==",
             "AccountName": "tdstdd"
           }
         ],
         "TimeFormat": "HH-mm"
       },
       "Type": "Microsoft.Storage/Blob"
     },
     "Diagnostics": null,
     "Serialization": {
       "Properties": {
         "Encoding": "UTF8",
         "Format": null
       },
       "Type": "Json"
     },
     "Type": "Reference"
   }
}

先將原本的 Input 刪除掉(請確定 Job 是否已停止),

Remove-AzureRMStreamAnalyticsInput -ResourceGroupName 你的resourceGroupName –JobName 你的JobName –Name 要修改的inputName

再新增 Input ,從 json 檔來,如下,

New-AzureRMStreamAnalyticsInput -ResourceGroupName 你的resourceGroupName -JobName 你的JobName –File "d:\Input.json剛才存的json" –Name 要修改的inputName -Force

從Portal看到的時間格式為空值,如下,

再啟動 Azure Stream Analytics Job ,就可以發現除了有 Input 也有 Output 了,如下,

參考資料

Monitor and manage Stream Analytics jobs with Azure PowerShell cmdlets

 

Hi, 

亂馬客Blog已移到了 「亂馬客​ : Re:從零開始的軟體開發生活

請大家繼續支持 ^_^