Bicep 为 Azure 数据工厂部署托管 VNet IR 时出错

Error in Bicep deployment of ManagedVNet IR for Azure Datafactory

我想在启用托管虚拟网络的情况下部署集成运行时资源。 在线查看代码似乎适用于以下结构:

resource IntegrationRuntime 'Microsoft.DataFactory/factories/integrationRuntimes@2018-06-01' = {
  name: 'integrationRuntime-${clientShortName}-${envName}'
  parent: adf
  properties: {
    description: 'Test Integration Runtime - Joao V1'
    type: 'Managed'
    // For remaining properties, see IntegrationRuntime objects
    typeProperties:{
      computeProperties:{
        location: 'UK South'
                dataFlowProperties: {
                    computeType: 'General'
                    coreCount: 8
                    timeToLive: 10
                    cleanup: false
        }
      }
    }
    managedVirtualNetwork:{
      type:'ManagedVirtualNetworkReference'
      referenceName: 'default'
    }
  }
}

但是,当我使用 yml 文件通过 CI-CD 管道在 DevOps 上部署它时,我收到以下错误消息:

状态消息:对托管虚拟网络的引用无效 'default'。托管虚拟网络不存在。 (代码:ManagedVNetReferencedNotExist) 错误出现在引用名称中,因为如果我使用其他名称重新运行脚本,新名称会显示在新错误消息中。这就引出了一个问题:那我应该使用什么参考名称?

如果我还尝试在 Azure 门户中手动部署它,启用托管 V 网络并创建新的 IR,它也会中断并发出相同的代码。 不知道这里可能出了什么问题。 DF 中唯一的其他 IR 是标准的 (AutoResolveIntegrationRuntime)

您需要先创建一个 VNET,然后再在参考中提供名称,或者您也可以使用 existing VNET 名称。

如果你有 existing VNET 那么你可以使用下面的代码:

param dfName string
param vnetname string 

 resource df 'Microsoft.DataFactory/factories@2018-06-01' = {
   name: dfName
   location: resourceGroup().location
   identity: {
     type: 'SystemAssigned'
   }
 }

 resource integrationRuntime 'Microsoft.DataFactory/factories/integrationRuntimes@2018-06-01' = {
   parent: df
   name: '${dfName}-managedVnetIr' 
   properties: {
     type: 'Managed'
     typeProperties: {
       computeProperties: {
         location: 'AutoResolve'
         dataFlowProperties: {
           computeType: 'General'
           coreCount: 8
           timeToLive: 0
         }
       }
     }
   }
 } 
 resource managedVnet 'Microsoft.DataFactory/factories/managedVirtualNetworks@2018-06-01' = {
   parent:df
   name: vnetname
   properties: { 
   }
   dependsOn: [
     integrationRuntime
   ]
 }

输出:


如果您没有VNET,则使用以下代码在同一模板中创建 VNET、ADF 和 IR:

param dfName string 
param virtualNetworkName string = 'azure_adf_vnet'
param subnetName string = 'azure_adf_subnet'
param vnetAddressPrefix string = '10.0.0.0/16'
param subnetPrefix string = '10.0.0.0/16'

resource virtualNetworkName_resource 'Microsoft.Network/virtualNetworks@2020-06-01' = {
  name: virtualNetworkName
  location: resourceGroup().location
  properties: {
    addressSpace: {
      addressPrefixes: [
        vnetAddressPrefix
      ]
    }
  }
}

resource virtualNetworkName_subnetName 'Microsoft.Network/virtualNetworks/subnets@2020-06-01' = {
  parent: virtualNetworkName_resource
  name: subnetName
  location: resourceGroup().location
  properties: {
    addressPrefix: subnetPrefix
  }
}

 resource df 'Microsoft.DataFactory/factories@2018-06-01' = {
   name: dfName
   location: resourceGroup().location
   identity: {
     type: 'SystemAssigned'
   }
 }  

 resource integrationRuntime 'Microsoft.DataFactory/factories/integrationRuntimes@2018-06-01' = {
   parent: df
   name: '${dfName}-managedVnetIr' 
   properties: {
     type: 'Managed'
     typeProperties: {
       computeProperties: {
         location: 'AutoResolve'
         dataFlowProperties: {
           computeType: 'General'
           coreCount: 8
           timeToLive: 0
         }
       }
     }
   }
 } 
 resource managedVnet 'Microsoft.DataFactory/factories/managedVirtualNetworks@2018-06-01' = {
   parent:df
   name: virtualNetworkName
   properties: { 
   }
   dependsOn: [
     integrationRuntime
   ]
 }

输出: