gpt4 book ai didi

azure - 仅具有 IP 地址的 Azure 负载均衡器中的 backendAddressPool 无法部署

转载 作者:行者123 更新时间:2023-12-03 06:20:55 25 4
gpt4 key购买 nike

我想部署一个仅包含 IP 地址的 Azure 负载均衡器 - 这不是指 Azure VM/VMSS NIC,而是指通用连接的本地服务器 - 与 Bicep 类似:

resource ilb 'Microsoft.Network/loadBalancers@2022-05-01' = {
name: ilbName
...
backendAddressPools: [
{
name: 'direct'
properties: {
loadBalancerBackendAddresses: [
{
name: 'server65'
properties: {
ipAddress: '192.168.42.65'
virtualNetwork: {
id: vnetHubId
}
}
}
{
name: 'server66'
properties: {
ipAddress: '192.168.42.66'
virtualNetwork: {
id: vnetHubId
}
}
}
]
}
}
]
...

但是部署后 - 即使在 Debug模式下也不会显示任何错误 - 门户中不会显示 IP 地址,并且在使用 CLI 检查时:

> az network lb address-pool show --lb-name ilb-123456789012 -g portfwd-rg -n direct
{
"etag": "W/\"037f2314-c311-4378-9486-a076cacc7491\"",
"id": "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/portfwd-rg/providers/Microsoft.Network/loadBalancers/ilb-123456789012/backendAddressPools/direct",
"loadBalancerBackendAddresses": [],
"loadBalancingRules": [
{
"id": "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/portfwd-rg/providers/Microsoft.Network/loadBalancers/ilb-123456789012/loadBalancingRules/direct",
"resourceGroup": "portfwd-rg"
}
],
"name": "direct",
"provisioningState": "Succeeded",
"resourceGroup": "portfwd-rg",
"type": "Microsoft.Network/loadBalancers/backendAddressPools"

使用 CLI 创建后端地址池时,它可以工作:

> az network lb address-pool create --lb-name ilb-123456789012 -g portfwd-rg -n direct2 \
--backend-address name=server65 ip-address=192.168.42.65 \
--backend-address name=server66 ip-address=192.168.42.66 \
--vnet /subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/portfwd-rg/providers/Microsoft.Network/virtualNetworks/vnet-hub-123456789012
> az network lb address-pool show --lb-name ilb-123456789012 -g portfwd-rg -n direct2
{
"etag": "W/\"efeef00f-3dd4-4b7c-bfa3-f58030757dea\"",
"id": "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/portfwd-rg/providers/Microsoft.Network/loadBalancers/ilb-123456789012/backendAddressPools/direct2",
"loadBalancerBackendAddresses": [
{
"ipAddress": "192.168.42.65",
"name": "server65",
"virtualNetwork": {
"id": "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/portfwd-rg/providers/Microsoft.Network/virtualNetworks/vnet-hub-123456789012",
"resourceGroup": "portfwd-rg"
}
},
{
"ipAddress": "192.168.42.66",
"name": "server66",
"virtualNetwork": {
"id": "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/portfwd-rg/providers/Microsoft.Network/virtualNetworks/vnet-hub-123456789012",
"resourceGroup": "portfwd-rg"
}
}
],
"name": "direct2",
"provisioningState": "Succeeded",
"resourceGroup": "portfwd-rg",
"type": "Microsoft.Network/loadBalancers/backendAddressPools"
}
<小时/>

编辑:所以我基本上将 az network lb address-pool create--debug/PUT 请求正文映射到 Bicep。这是 PUT 请求正文:

{"name": "direct", "properties": {"loadBalancerBackendAddresses": [{"name": "server65", "properties": {"ipAddress": "192.168.42.65", "virtualNetwork": {"id": "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/portfwd-rg/providers/Microsoft.Network/virtualNetworks/vnet-hub-123456789012"}}}, {"name": "server66", "properties": {"ipAddress": "192.168.42.66", "virtualNetwork": {"id": "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/portfwd-rg/providers/Microsoft.Network/virtualNetworks/vnet-hub-123456789012"}}}]}}
<小时/>

我错过了什么或做错了什么?

最佳答案

我也遇到了类似的问题。在没有看到您的所有代码的情况下,我将向您确定我做了什么来解决我的问题。希望对您有帮助。

main.bicep

param location string = resourceGroup().location

var loadBalancerName = 'dev-web01-LB'
var virtualNetworkName = 'dev-dev-VNET'
var subnetName = 'dev-web-Net'
var subnetRef = resourceId('Microsoft.Network/virtualNetworks/subnets', virtualNetworkName, subnetName)

resource loadBalancers_name 'Microsoft.Network/loadBalancers@2022-07-01' = {
name: loadBalancerName
location: location
sku: {
name: 'Standard'
tier: 'Regional'
}
properties: {
frontendIPConfigurations: [
{
name: 'FrontendIP'
id: resourceId('Microsoft.Network/loadBalancers/frontendIpConfigurations', loadBalancerName, 'FrontendIP')
properties: {
privateIPAddress: '192.168.42.196'
privateIPAllocationMethod: 'Static'
subnet: {
id: subnetRef
}
privateIPAddressVersion: 'IPv4'
}
}
]
backendAddressPools: [
{
name: 'BackendPool'
}
]
loadBalancingRules: [
// Start of Rule
{
name: 'server65'
id: resourceId('Microsoft.Network/loadBalancers/frontendIpConfigurations', loadBalancerName, 'server65')
properties: {
frontendIPConfiguration: {
id: resourceId('Microsoft.Network/loadBalancers/frontendIpConfigurations', loadBalancerName, 'FrontendIP')
}
frontendPort: 605
backendPort: 605
enableFloatingIP: false
idleTimeoutInMinutes: 4
protocol: 'Tcp'
enableTcpReset: false
loadDistribution: 'Default'
disableOutboundSnat: false
backendAddressPool: {
id: resourceId('Microsoft.Network/loadBalancers/backendAddressPools', loadBalancerName, 'BackendPool')
}
backendAddressPools: [
{
id: resourceId('Microsoft.Network/loadBalancers/backendAddressPools', loadBalancerName, 'BackendPool')
}
]
probe: {
id: resourceId('Microsoft.Network/loadBalancers/probes', loadBalancerName, 'HealthProbe')
}
}
}
// End of Rule
{
name: 'server66'
id: resourceId('Microsoft.Network/loadBalancers/frontendIpConfigurations', loadBalancerName, 'server66')
properties: {
frontendIPConfiguration: {
id: resourceId('Microsoft.Network/loadBalancers/frontendIpConfigurations', loadBalancerName, 'FrontendIP')
}
frontendPort: 606
backendPort: 606
enableFloatingIP: false
idleTimeoutInMinutes: 4
protocol: 'Tcp'
enableTcpReset: false
loadDistribution: 'Default'
disableOutboundSnat: false
backendAddressPool: {
id: resourceId('Microsoft.Network/loadBalancers/backendAddressPools', loadBalancerName, 'BackendPool')
}
backendAddressPools: [
{
id: resourceId('Microsoft.Network/loadBalancers/backendAddressPools', loadBalancerName, 'BackendPool')
}
]
probe: {
id: resourceId('Microsoft.Network/loadBalancers/probes', loadBalancerName, 'HealthProbe')
}
}
}
]
probes: [
{
name: 'HealthProbe'
id: resourceId('Microsoft.Network/loadBalancers/probes', loadBalancerName, 'HealthProbe')
properties: {
protocol: 'Tcp'
port: 8483
intervalInSeconds: 5
numberOfProbes: 1
probeThreshold: 1
}
}
]
}
}

module devweb01vm './dev-web01-vm.bicep' = {
name: 'dev-web01-VM'
scope: resourceGroup('dev-dev-RG')
params: {
location: location
}
dependsOn: [
loadBalancers_name
]
}

module devweb02vm './dev-web02-vm.bicep' = {
name: 'dev-web02-VM'
scope: resourceGroup('dev-dev-RG')
params: {
location: location
}
dependsOn: [
loadBalancers_name
]
}

dev-web01-vm.bicep

param location string = resourceGroup().location

var virtualNetworkName = 'dev-dev-VNET'
var loadBalancerName = 'dev-web01-LB'
var subnetName = 'dev-web-Net'
var subnetRef = resourceId('Microsoft.Network/virtualNetworks/subnets', virtualNetworkName, subnetName)

resource dev_web01_VM_nic 'Microsoft.Network/networkInterfaces@2022-07-01' = {
name: 'dev-web01-vm-Nic'
location: location
properties: {
ipConfigurations: [
{
name: 'ipconfig1'
type: 'Microsoft.Network/networkInterfaces/ipConfigurations'
properties: {
privateIPAddress: '192.168.42.250'
privateIPAllocationMethod: 'Static'
subnet: {
id: subnetRef
}
primary: true
privateIPAddressVersion: 'IPv4'
loadBalancerBackendAddressPools: [
{
id: resourceId('Microsoft.Network/loadBalancers/backendAddressPools', loadBalancerName, 'BackendPool')
}
]
}
}
]
}
}

dev-web02-vm.bicep

param location string = resourceGroup().location

var virtualNetworkName = 'dev-dev-VNET'
var loadBalancerName = 'dev-web01-LB'
var subnetName = 'dev-web-Net'
var subnetRef = resourceId('Microsoft.Network/virtualNetworks/subnets', virtualNetworkName, subnetName)

resource dev_web02_vm_nic 'Microsoft.Network/networkInterfaces@2022-07-01' = {
name: 'dev-web02-vm-Nic'
location: location
properties: {
ipConfigurations: [
{
name: 'ipconfig1'
type: 'Microsoft.Network/networkInterfaces/ipConfigurations'
properties: {
privateIPAddress: '192.168.42.251'
privateIPAllocationMethod: 'Static'
subnet: {
id: subnetRef
}
primary: true
privateIPAddressVersion: 'IPv4'
loadBalancerBackendAddressPools: [
{
id: resourceId('Microsoft.Network/loadBalancers/backendAddressPools', loadBalancerName, 'BackendPool')
}
]
}
}
]
}
}

关于azure - 仅具有 IP 地址的 Azure 负载均衡器中的 backendAddressPool 无法部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75910542/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com