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