【问题标题】:Bicep to Deploy Data Factory Managed Virtual Network二头肌部署数据工厂管理的虚拟网络
【发布时间】:2021-10-14 10:25:22
【问题描述】:

我正在尝试创建一个二头肌模块,该模块将部署数据工厂和托管 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

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

“状态”:“失败”, “错误”: { "code": "ResourceNotFound", “消息”:“找不到资源。ResourceId:'/subscriptions/8210b2ab-404f-40a5-baba-1cde6d89c670/resourceGroups/rg-contactcentre-dev-001/providers/Microsoft.DataFactory/factories/df-ccsurvey-dev-001 /managedvirtualnetworks/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

但这会产生以下错误:

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

谁能发现我做错了什么或者请指导我找到一个工作示例?

【问题讨论】:

  • 你好@Rob Bowman,我测试了 SQL 数据库并添加了一个更新来回答,如果可行,请告诉我..
  • 你好@Rob Bowman,我根据你的场景和你需要的配置更新了代码。我已经对其进行了测试,并且已成功部署。请使用我在更新:2 部分中提供的整个代码。它将创建一个 vnet,然后是 sql server 和 adf,最后在 adf 中为 sql 管理 privateendpoint。

标签: azure-data-factory azure-resource-manager azure-bicep


【解决方案1】:

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

更新:1

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

在测试 SQL server 时,我发现了两个问题,即 groupId 应该是 sqlServer 以及 adf 的托管 vnet 将无法与 sql server 通信,因为它没有添加到 @ 987654332@.

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

  1. 如果您引用 Microsoft.SQL/Servers,请将 groupID 更改为 sqlServer,如果您引用“Microsoft.Synapse/Workspaces”,则可以将其保留为 sql。 您可以参考此Microsoft Document 获取私有端点子资源名称。

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

以上两步完成后,部署成功。


更新: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
   ]
 }

输出:

注意:部署成功后,您需要手动从SQL Server批准私有端点请求,该请求处于挂起状态,如下所示:

【讨论】:

  • 我按照您的建议进行了修改。我的二头肌模块现在接收现有 vnet 的名称,并在管理的 vnet 资源的 name 属性中使用它。部署运行了 1 小时 18 分钟,但在部署类型“managedPrivateEndpoints”时失败并出现错误:资源操作已完成,终端配置状态为“失败”。
  • 嗨,它正在为 sql 部署端点。 sql id 是二头肌模块的输出,该模块在序列中较早地被调用以创建 sql 实例:resource sqlServerName_resource 'Microsoft.Sql/servers@2015-05-01-preview' = { name: sqlServerName location: resourceGroup ().location 属性:{ administratorLogin: sqlAdminUsername administratorLoginPassword: sqlAdminPwd } } output sqlId string = sqlServerName_resource.id
  • 嗨@AnsumanBal-MT 恐怕它不起作用。请看我对您的回答的第一条评论
  • @RobBowman,我已经用新代码更新了答案,并更新了部署 SQL 后要遵循的几个步骤。让我尝试顺序部署以及部署 SQL 服务器时需要配置的内容之后,我将尝试将 adf 与 SQL 服务器的托管私有端点部署为子资源。我会在测试后尝试更新你。如果我对你正在尝试的场景有误,请告诉我。。
  • 我认为你是正确的。我有一个“主”二头肌模板,它接收预先存在的 vnet 的名称作为参数。 Main 在返回创建的 sql 实例的 id 时调用“Sql”模板。然后它将它与 vnet 名称一起传递给“DataFactory”二头肌模板,该模板尝试创建:数据工厂、集成运行时、托管 vnet、托管私有端点
猜你喜欢
  • 2022-06-16
  • 1970-01-01
  • 1970-01-01
  • 2021-10-26
  • 2021-05-04
  • 1970-01-01
  • 2021-07-05
  • 2011-09-08
  • 1970-01-01
相关资源
最近更新 更多