2

我們目前正在通過Azure流分析將數據從Azure事件中心流式傳輸到Cosmos數據庫。我希望能夠以編程方式更改在數據流式傳輸時完成的查詢(/ Transformation)。Azure流分析CreateOrReplace轉換衝突或錯誤請求

var existingQuery = AnalyticsClient.Transformations.Get(handler.ResourceGroup, handler.JobName, handler.JobName); 

if (job.JobState == "Started") 
     { 
      AnalyticsClient.StreamingJobs.BeginStopAsync(handler.ResourceGroup, handler.JobName).Wait(); 
     } 
     var transformation = new Transformation() 
     { 
      Query = [email protected]"SELECT 
         [key] as partition_key 
        INTO[{outputName}] 
        FROM Input", 
      StreamingUnits = 1 
     }; 
AnalyticsClient.Transformations.CreateOrReplace(transformation, handler.ResourceGroup, handler.JobName, handler.JobName); 

Stream Analytics Job Properties - 轉換顯示爲空。

目前尚不清楚改造的默認名稱可能是,但試圖獲得(作爲作業同名)的工作轉換

{ 
    "code": "NotFound", 
    "message": "StreamAnalytics_Prototype_2 does not exist in Stream Analytics job 'StreamAnalytics_Prototype_2' in resource group 'removed' in subscription 'removed'.", 
    "details": { 
     "code": "404", 
     "message": "StreamAnalytics_Prototype_2 does not exist in Stream Analytics job 'StreamAnalytics_Prototype_2' in resource group 'removed' in subscription 'removed'.", 
     "correlationId": "removed", 
     "requestId": "removed" 
    } 
} 

試圖建立一個轉型

{ 
    "code": "BadRequest", 
    "message": "The number of transformations defined for this job exceeds the maximum limit of 1 that is supported.", 
    "details": { 
     "code": "400", 
     "message": "The number of transformations defined for this job exceeds the maximum limit of 1 that is supported." 
    } 
} 

回答

2

如果您從Azure的門戶網站轉型,默認名稱是轉換「轉型」。如果您從SDK創建轉換,則需要在代碼中指定名稱。

streamAnalyticsManagementClient.Transformations.CreateOrReplace(transformation, resourceGroupName, streamingJobName, transformationName); 

順便說一下,從Azure門戶添加查詢後,我從Activity日誌中找到了默認轉換名稱。

enter image description here

+0

非常感謝;這也是有用的:var streamingjob = AnalyticsClient.StreamingJobs.Get(ResourceGroup,JobName,「transformation」); – DanAdrenaline

+0

我還有一個Stream,在這個Stream下查詢被命名爲腳本(我假設一個開發者通過.net創建它),我可以通過活動日誌中的上述方法進行檢查。 – DanAdrenaline