通过ADF自动化AAS模型刷新时遇RefreshType格式错误求助
解决ADF自动化AAS模型刷新时RefreshType格式错误问题
问题根源
你遇到的错误是因为Web活动的Body字段被二次转义,导致AAS收到的请求是嵌套的字符串而非正确的JSON结构。SQL生成的JSON字符串被Lookup活动获取后,ADF默认将其视为普通字符串,在传递给Web活动时自动添加转义符,使得refresh字段的值变成了一个字符串,而非JSON对象,从而触发RefreshType格式错误。
解决方案
1. 确认SQL生成的JSON结构正确
确保SQL生成的JSON符合AAS刷新API的要求,正确结构如下:
{ "refresh": { "type": "Full", "objects": [ {"database": "Self Service MI - Registrations", "table": "Dim - Conferences"}, {"database": "Self Service MI - Registrations", "table": "Dim - Boothscan"}, {"database": "Self Service MI - Registrations", "table": "Dim - Tags"}, {"database": "Self Service MI - Registrations", "table": "Dim - Sponsors"} ] } }
SQL生成时不要额外添加转义符或嵌套引号,直接生成上述格式的字符串存入表中。
2. 在Web活动中解析JSON字符串
不要直接将Lookup的结果赋值给Body,而是使用ADF的@json()函数将字符串转换为JSON对象:
- 假设Lookup活动名称为
Lookup_Refresh_Config,存储JSON的列名为RefreshJson,则Web活动的Body设置为:@json(activity('Lookup_Refresh_Config').firstRow.RefreshJson)
3. 验证Web活动输入
设置完成后,查看Web活动的输入,Body部分应呈现无转义符的正确JSON结构,示例如下:
{ "refresh": { "type": "Full", "objects": [ {"database": "Self Service MI - Registrations", "table": "Dim - Conferences"}, {"database": "Self Service MI - Registrations", "table": "Dim - Boothscan"}, {"database": "Self Service MI - Registrations", "table": "Dim - Tags"}, {"database": "Self Service MI - Registrations", "table": "Dim - Sponsors"} ] } }
4. 额外检查项
- 确认MSI拥有AAS的Azure Analysis Services Contributor角色权限,避免权限问题导致的请求失败。
RefreshType的取值要符合要求:字符串类型需首字母大写(如"Full"),数字类型对应正确映射(1=Full、2=Automatic等)。
内容的提问来源于stack exchange,提问作者Abjangra
相关产品推荐
相关产品推荐

