答案 0 :(得分:1)
您当然可以!以下是使用Azure CLI的一些示例代码:
# create an Azure Load Balancer that is associated to a virtual network
# instead of a public IP:
$ az network lb create -g multirg -n privatealb --vnet-name vnet --subnet scalesetsubnet
# create an application gateway:
$ az network application-gateway create -g multirg -n appgw --vnet-name vnet --subnet appgwsubnet
# create a scale set associated with the app gateway (note: 'az vmss create'
# does not allow specifying multiple load balancers; we'll just create with
# the app gateway for now and add the Azure Load Balancers afterwards)
$ az vmss create -g multirg -n scaleset --app-gateway appgw --image UbuntuLTS --generate-ssh-keys --vnet-name vnet --subnet scalesetsubnet --upgrade-policy Automatic
# to associate the scale set with the load balancer post-creation,
# we will need to know the resource IDs of the load balancer's backend
# pool; we can get this using the 'az network lb show' command:
$ az network lb show -g multirg -n privatealb
{
"backendAddressPools": [
{
.
.
.
"id": "{private-alb-pool-id}",
.
.
.
}
# we can then use the 'az vmss update' command to associate the Azure
# Load Balancer with the scale set:
az vmss update --resource-group multirg --name scaleset --add virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].ipConfigurations[0].LoadBalancerBackendAddressPools '{"id": "{private-alb-pool-id}"}'
我还写了一篇简短的博客文章,描述了规模集+ Azure负载均衡器+ App Gateway方案。有关更多信息,请在这里找到:https://negatblog.wordpress.com/2018/06/21/scale-sets-and-load-balancers/
希望这会有所帮助! :) -尼尔