Azure (ARM) で構成されたロード バランサーがあり、prod、stage の 2 つのバックエンド プールがあります。GUI を使用して、ステージング サーバーを本番環境に昇格させたい場合は、それをステージ プールから削除して、本番プールに配置します。スタックをプロビジョニングするときは、最初にロード バランサーをプロビジョニングし、VM が接続する NIC をプロビジョニングするときは、必要なバックエンド プールにその NIC を配置するため、これがどのように機能するかについて非常に混乱しています。ただし、VM を別のプールに移動したい場合、NIC レベルでそれを行うことはなくなりました。ロードバランサーでそれを行う必要があります。
Python SDK を使用して、LB にクエリを実行するとバックエンド プールにある NIC を確認できますが、それを変更する方法はないようです。また、NIC にクエリを実行して、関連付けられているバックエンド プールを確認することもできますが、変更する方法はありません (私が知る限り)。これは私がこれまでに持っているものです:
# Create the client
network_client = azure.mgmt.network.NetworkResourceProviderClient(creds)
# Get all LBs
lbs = network_client.load_balancers
# select LB in question
lb = lbs.get(group,'cc-lb01')
# get all pools
pools = lb.load_balancer.backend_address_pools
# set variables for pools
prod = pools[0]
stage = pools[1]
print(dir(stage)) の出力は次のとおりです。
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_backend_ip_configurations', '_etag', '_id', '_load_balancing_rules', '_name', '_provisioning_state', 'backend_ip_configurations', 'etag', 'id', 'load_balancing_rules', 'name', 'provisioning_state']
それで、「backend_ip_configurations」を見たとき、何かに気づいたと思いました。そこで私のオプションを見ると(これを入力して):
print(stage.backend_ip_configurations)
オブジェクトの配列を返します。
[<azure.mgmt.network.networkresourceprovider.ResourceId object at 0x03C9C090>]
その配列には項目が 1 つしかないため、その項目を変数に設定します。
beip = stage.backend_ip_configurations[0].id
そして、「beip」のオプションを確認すると、ここで行き止まりになります。
/subscriptions/xxx-xxx-xxx/resourceGroups/myresourcegroup/providers/Microsoft.Network/networkInterfaces/app-green04-nic/ipConfigurations/ipconfig1
print(dir(beip)) の出力は次のとおりです。
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
バックエンド プールにある NIC を確認し、GUI 以外でそのプールを変更する方法がわかりません。