You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过Bicep部署文件系统API连接成功,但逻辑应用工作流无法使用

解决Bicep部署本地网关文件系统API连接后运行时验证失败的问题

问题背景

通过Bicep部署集成本地数据网关的文件系统API连接后,逻辑应用执行文件系统操作时抛出错误:

"The requested action could not be completed. Check your request parameters to make sure the path '\\folder\\Input' exists on your file system."

但在Azure门户进入该API连接,编辑并重新保存用户名密码后,连接立即恢复正常。已验证从Key Vault获取的用户名/密码有效,且逻辑应用已配置VNET集成。

根因分析

问题出在API连接的参数结构配置错误:你将认证凭据(用户名/密码)放在了parameterValues字段中,但文件系统Managed API要求凭据必须存放在authentication属性块内。部署时Bicep按照错误的结构提交配置,导致本地网关无法正确读取认证信息;而手动保存时,Azure门户会自动修正参数结构,并触发本地网关的凭据同步流程,因此连接恢复正常。

解决方案

修正Bicep模块中的API连接资源定义,将用户名和密码移至authentication属性下,具体代码如下:

param location string = resourceGroup().location
param logicAppName string = 'lapp-xxx-test'

@secure()
param userName string

@secure()
param password string

// RESOURCES
resource apiConnectionResource 'Microsoft.Web/connections@2016-06-01' = {
  name: 'apiconn-file-test'
  location: location
  kind: 'V2'
  tags: {}
  properties: {
    displayName: 'apiconn-file-test'
    parameterValues: {
      rootfolder: '\\\\NASFOLDER\\TEST'
      authType: 'windows'
      gateway: {
        id: '/subscriptions/xxx-xxx-xxx-xxx-xxx/resourceGroups/xxx/providers/Microsoft.Web/connectionGateways/xxx-On-Prem-Gateway'
      }
    }
    // 正确存放认证凭据的位置
    authentication: {
      type: 'Basic'
      parameters: {
        username: userName
        password: password
      }
    }
    api: {
      id: '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Web/locations/westeurope/managedApis/filesystem'
    }
  }
}

resource accessPolicy 'Microsoft.Web/connections/accessPolicies@2016-06-01' = {
  name: '${apiConnectionResource.name}/${logicAppName}'
  location: location
  properties: {
    principal: {
      type: 'ActiveDirectory'
      identity: {
        tenantId: subscription().tenantId
        objectId: reference('/subscriptions/${subscription().subscriptionId}/resourceGroups/${resourceGroup().name}/providers/Microsoft.Web/sites/${logicAppName}','2021-02-01','full').identity.principalId
      }
    }
  }
}

额外注意事项

  1. 确保部署Bicep的服务主体拥有Key Vault的getSecret权限,以及API连接资源的写入权限
  2. 若部署后仍有问题,可查看本地网关的日志,确认凭据是否已成功同步到网关侧

内容的提问来源于stack exchange,提问作者Morty

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 11:17:54