Azure流分析CreateOrReplace转换冲突或错误请求

时间:2017-07-18 15:47:27

标签: azure azure-cosmosdb azure-eventhub azure-stream-analytics

我们目前正在通过Azure Stream Analytics将数据从Azure事件中心流式传输到Cosmos DB。我希望能够以编程方式更改在数据流传输时完成的查询(/ Transformation)。

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 = $@"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 - 转换显示为null。

目前还不清楚转换的默认名称是什么,但尝试从作业中获得转换(与作业同名):

{
    "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."
    }
}

1 个答案:

答案 0 :(得分:2)

如果从Azure门户创建转换,则默认名称用于转换“转换”。如果您从SDK创建转换,则需要在代码中指定名称。

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

顺便说一句,我从Azure门户添加了一个查询后,从活动日志中找到了默认的转换名称。

enter image description here