Bicep 部署数据工厂托管虚拟网络
Bicep to Deploy Data Factory Managed Virtual Network
我正在尝试创建一个 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": "Failed",
"error": {
"code": "ResourceNotFound",
"message": "Resource not found. 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
但这会产生以下错误:
{
"status": "Failed",
"error": {
"code": "ResourceDeploymentFailure",
"message": "The resource operation completed with terminal provisioning state 'Failed'."
} }
任何人都可以发现我做错了什么或指导我使用工作示例吗?
要在数据工厂上创建托管虚拟网络,您必须引用资源组中的现有 Vnet。
更新:1
在测试为 sql 数据库创建托管专用端点时,我遇到了与您相同的错误,使用您的代码,它在 1 小时 18 分钟后失败,配置失败。
当我测试 SQL 服务器时,我发现了两个问题,即 groupId
应该是 sqlServer
以及 adf 的托管 vnet 将无法通信使用 sql 服务器,因为它没有添加到 firewall and virtual networks
.
要解决此问题,您需要执行以下两个步骤:
如果您正在引用 Microsoft.SQL/Servers
,请将组 ID 更改为 sqlServer
,如果您正在引用 'Microsoft.Synapse/Workspaces',您可以将其保留为 sql
。
您可以参考此 Microsoft Document 获取私有端点子资源名称。
请添加您正在使用的现有虚拟网络,以便在 SQL 服务器中为 ADF 创建托管虚拟网络。 (如果您引用的是突触,则转到突触>>网络>>允许 Azure 服务和资源访问此工作区)
完成以上2步后,部署就成功了。
更新:2
场景:使用 Vnet 创建一个 SQL 服务器,然后引用 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服务器的处于待定状态的专用端点请求,如下所示:
我正在尝试创建一个 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": "Failed", "error": { "code": "ResourceNotFound", "message": "Resource not found. 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
但这会产生以下错误:
{ "status": "Failed", "error": { "code": "ResourceDeploymentFailure", "message": "The resource operation completed with terminal provisioning state 'Failed'." } }
任何人都可以发现我做错了什么或指导我使用工作示例吗?
要在数据工厂上创建托管虚拟网络,您必须引用资源组中的现有 Vnet。
更新:1
在测试为 sql 数据库创建托管专用端点时,我遇到了与您相同的错误,使用您的代码,它在 1 小时 18 分钟后失败,配置失败。
当我测试 SQL 服务器时,我发现了两个问题,即 groupId
应该是 sqlServer
以及 adf 的托管 vnet 将无法通信使用 sql 服务器,因为它没有添加到 firewall and virtual networks
.
要解决此问题,您需要执行以下两个步骤:
如果您正在引用
Microsoft.SQL/Servers
,请将组 ID 更改为sqlServer
,如果您正在引用 'Microsoft.Synapse/Workspaces',您可以将其保留为sql
。 您可以参考此 Microsoft Document 获取私有端点子资源名称。请添加您正在使用的现有虚拟网络,以便在 SQL 服务器中为 ADF 创建托管虚拟网络。 (如果您引用的是突触,则转到突触>>网络>>允许 Azure 服务和资源访问此工作区)
完成以上2步后,部署就成功了。
更新:2
场景:使用 Vnet 创建一个 SQL 服务器,然后引用 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服务器的处于待定状态的专用端点请求,如下所示: