问题描述
我目前正在尝试创建一个 Bicep 模板,该模板将部署一个存储帐户,将其限制到适当的现有 vnet 以及部署一个私有端点并将其链接到我们现有私有 DNS 区域中的不同的订阅并创建 A 记录。目前,模板会将存储帐户部署到适当的 vnet 并部署一个新的私有端点,但我对如何让它链接到现有的私有 dns 区域并创建 A 记录感到困惑。任何帮助将不胜感激。谢谢!
resource stg 'Microsoft.Storage/storageAccounts@2020-08-01-preview' = {
name: name
location: location
sku: {
name: storageSku
}
kind: 'StorageV2'
properties: {
minimumTlsVersion: 'TLS1_2'
allowBlobPublicAccess: true
networkAcls: {
bypass: 'AzureServices'
virtualNetworkRules: [
{
id: '${}'
action: 'Allow'
}
]
ipRules: []
defaultAction: 'Deny'
}
}
}
resource privateEndpointName_resource 'Microsoft.Network/privateEndpoints@2019-04-01' = {
name: privateEndpointName
location: location
properties: {
privateLinkServiceConnections: [
{
name: privateEndpointName
properties: {
privateLinkServiceId: resourceId('Microsoft.Storage/storageAccounts',stg.name)
groupIds: [
groupId
]
}
}
]
manualPrivateLinkServiceConnections: []
subnet: {
id: '${}'
}
}
}
resource privateDNSZone_name 'Microsoft.Network/privateDnsZones@2018-09-01' existing = {
scope: resourceGroup(,)
name: privateDNSZone_name_var
}
resource privateDNSZone_name_vnetName_link 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2018-09-01' existing = {
scope: resourceGroup(,)
name: '${}'
}
resource privateEndpointName_default 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2020-03-01' existing = {
name: '${privateEndpointName_resource.name}/default'
}
解决方法
这是一个使用 sqlserver privatelink 的例子,但对于存储应该是类似的:
resource privateEndpoint 'Microsoft.Network/privateEndpoints@2020-06-01' = {
name: '${sqlServer.name}-plink'
location: location
properties: {
subnet: {
id: privateLinkSnetId
}
privateLinkServiceConnections: [
{
name: '${sqlServer.name}-plink'
properties: {
privateLinkServiceId: sqlServer.id
groupIds: [
'sqlServer'
]
}
}
]
}
}
resource privateDNSZoneGroup 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2020-06-01' = {
name: '${privateEndpoint.name}/default'
properties: {
privateDnsZoneConfigs: [
{
name: 'privatelink-database-windows-net'
properties: {
privateDnsZoneId: privateLinkDnsZoneId
}
}
]
}
}
但是请记住,没有指向存储帐户的链接 - 每个服务:blob、队列、表、文件都有自己的链接。
当您将私有端点链接到 dns 区域时,应自动创建 A 记录。
但是,如果要跨资源组或跨订阅部署,则需要使用模块 - 您不能将资源部署到一个文件(模块)内的不同范围,但可以创建该资源组部署在此相同或不同订阅中的不同资源组中创建另一个部署。