Home > Software engineering >  Error in Bicep deployment of ManagedVNet IR for Azure Datafactory
Error in Bicep deployment of ManagedVNet IR for Azure Datafactory

Time:11-10

I want to deploy a Integration runtime resource with a managed Virtual network enabled. Looking online the code seems to work for the following structure:

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'
    }
  }
}

However, when I deploy it via CI-CD pipelines on DevOps with a yml file, I get the following error message:

Status Message: Invalid reference to the managed Virtual Network 'default'. The managed Virtual Network does not exist. (Code:ManagedVNetReferencedNotExist) The error is in the Reference Name, because if I rerun the script with the other name, the new name shows on the new error message. This begs the question: What Reference Name should I use then?

If I also try to manually deploy it in the azure Portal, of I enable managed V net, and create a new IR, it also breaks and issues the same code. Not sure what could be wrong here. The only other IR in the DF is the standard one (AutoResolveIntegrationRuntime)

CodePudding user response:

You need to create a VNET first before providing the name in the reference or you can use existing VNET Name as well.

If you have and existing VNET then you can use the below code:

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
   ]
 }

Outputs:

enter image description here

enter image description here


If you don't have VNET then use the below code to create a VNET , ADF and IR in the same template:

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
   ]
 }

Outputs:

enter image description here

enter image description here

enter image description here

  • Related