代码之家  ›  专栏  ›  技术社区  ›  Rob Bowman

Bicep部署数据工厂管理的虚拟网络

  •  0
  • Rob Bowman  · 技术社区  · 4 年前

    我正在尝试创建一个bicep模块,该模块将部署一个数据工厂和一个托管vnet。以下是我所拥有的:

    param dfName string
     param sqlId 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' = {
       name: '${dfName}/managedVnetIr' 
       properties: {
         type: 'Managed'
         typeProperties: {
           computeProperties: {
             location: 'AutoResolve'
             dataFlowProperties: {
               computeType: 'General'
               coreCount: 8
               timeToLive: 0
             }
           }
         }
       }
       dependsOn: [
         df
       ]
     }
        
     resource managedVnet 'Microsoft.DataFactory/factories/managedVirtualNetworks@2018-06-01' = {
       name: '${dfName}/vnet'
       properties: { 
       }
       dependsOn: [
         integrationRuntime
       ]
     }
        
     resource managedPrivateEndpoint 'Microsoft.DataFactory/factories/managedVirtualNetworks/managedPrivateEndpoints@2018-06-01' = {
       name: '${dfName}/vnet/pe'
       properties: {
         privateLinkResourceId:sqlId
         groupId: 'sql'
       }
       dependsOn: [
         managedVnet
       ]
     }
        
     output dfId string = df.identity.principalId
    

    运行此模块时,出现以下错误:

    “status”:“失败”, “错误”:{ “code”:“ResourceNotFound”, “message”:“未找到资源。资源ID:”/订阅/8210b2ab-404f-40a5-baba-1cde6d89c670/资源组/rg-contactcentre-dev-001/提供商/Microsoft。数据工厂/工厂/df-ccsurvey-dev-001/ManagedVirtualNetwork/vnet“。” }

    我还尝试了以下方法(基于AnsumanBal MT的回答)

    param dfName string
    param sqlId 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
      ]
    }
    
    resource managedPrivateEndpoint 'Microsoft.DataFactory/factories/managedVirtualNetworks/managedPrivateEndpoints@2018-06-01' = {
      parent:managedVnet
      name: '${vnetName}-sql-pe'
      properties: {
        privateLinkResourceId:sqlId
        groupId: 'sql'
      }
      dependsOn: [
        managedVnet
      ]
    }
    
    output dfId string = df.identity.principalId
    

    但这会产生以下错误:

    { “status”:“失败”, “错误”:{ “code”:“ResourceDeploymentFailure”, “message”:“资源操作已完成,终端设置状态为“失败”。” }}

    有谁能指出我做错了什么,或者告诉我一个工作样本吗?

    0 回复  |  直到 4 年前
        1
  •  1
  •   Ansuman Bal    4 年前

    要在数据工厂上创建托管虚拟网络,必须引用资源组中的现有Vnet。

    更新:1

    在测试为sql数据库创建托管私有端点时,我遇到了与您相同的错误,使用您的代码在1小时18分钟后失败,设置失败。

    在测试SQL server时,我发现了两个问题 groupId 应该是 sqlServer 此外,adf的托管vnet将无法与sql server通信,因为它未添加到 firewall and virtual networks 。

    要解决此问题,您需要遵循以下两个步骤:

    1. 如果您正在引用 Microsoft.SQL/Servers 请将groupID更改为 sqlServer 如果您引用的是“Microsoft”。Synapse/Workspace“您可以将其保留为 sql 。 你可以参考这个 Microsoft Document 专用终结点子资源名称。

    2. 请添加用于在SQL server中为ADF创建托管虚拟网络的现有虚拟网络。(如果您正在引用synapse,请转到synapse,允许Azure服务和资源访问此工作区)

    enter image description here

    完成上述两个步骤后,部署将成功。


    更新:2

    场景: 使用Vnet创建SQL Server,然后引用Vnet和SQL来创建adf管理的虚拟网络和专用端点。

    请使用我根据您的要求测试的以下代码:

    param serverName string = uniqueString('sql', resourceGroup().id)
    param sqlDBName string = 'SampleDB'
    param administratorLogin string
    @secure()
    param administratorLoginPassword string
    param virtualNetworkName string = 'azure_mysql_vnet'
    param subnetName string = 'azure_mysql_subnet'
    param virtualNetworkRuleName string = 'AllowSubnet'
    param vnetAddressPrefix string = '10.0.0.0/16'
    param subnetPrefix string = '10.0.0.0/16'
    param dfName string
    
    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 serverName_resource 'Microsoft.Sql/servers@2020-02-02-preview' = {
      name: serverName
      location: resourceGroup().location
      properties: {
        administratorLogin: administratorLogin
        administratorLoginPassword: administratorLoginPassword
      }
    }
    
    resource serverName_sqlDBName 'Microsoft.Sql/servers/databases@2020-08-01-preview' = {
      parent: serverName_resource
      name: sqlDBName
      location: resourceGroup().location
      sku: {
        name: 'Standard'
        tier: 'Standard'
      }
    }
    
    resource serverName_virtualNetworkRuleName 'Microsoft.Sql/servers/virtualNetworkRules@2021-02-01-preview' = {
      parent: serverName_resource
      name: virtualNetworkRuleName
      properties: {
        virtualNetworkSubnetId: virtualNetworkName_subnetName.id
        ignoreMissingVnetServiceEndpoint: true
      }
    }
    
     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
       ]
     }
        
     resource managedPrivateEndpoint 'Microsoft.DataFactory/factories/managedVirtualNetworks/managedPrivateEndpoints@2018-06-01' = {
       parent:managedVnet
       name: '${virtualNetworkName}-${serverName}-pe'
       properties: {
         privateLinkResourceId: serverName_resource.id
         groupId: 'sqlServer'
       }
       dependsOn: [
         managedVnet
       ]
     }
    

    输出:

    enter image description here

    enter image description here

    注: 部署成功后,需要手动批准SQL server中处于挂起状态的私有端点请求,如下所示:

    enter image description here

    推荐文章