Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Azure Python SDK - Networking - Network Interface - updating nic
import os
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.network import NetworkManagementClient
subscription_id = os.environ.get(
'AZURE_SUBSCRIPTION_ID',
'11111111-1111-1111-1111-111111111111') # your Azure Subscription Id
credentials = ServicePrincipalCredentials(
client_id=os.environ['AZURE_CLIENT_ID'],
secret=os.environ['AZURE_CLIENT_SECRET'],
tenant=os.environ['AZURE_TENANT_ID']
)
network_client = NetworkManagementClient(credentials, subscription_id)
# Info can be found here https://github.com/Azure/azure-sdk-for-python/blob/master/azure-mgmt-network/azure/mgmt/network/v2017_06_01/models/network_interface.py
def modify_nic(nic):
#make changes to <azure.mgmt.network.v2017_06_01.models.NetworkInterface> type
return nic
# Get interface card
resource_group_name = "[resource group name]"
nic_name ="[name of the nic]"
nic = network_client.network_interfaces.get(resource_group_name, nic_name)
if nic:
modify_nic(nic)
async_nic_update = network_client.network_interfaces.create_or_update(
resource_group_name,
nic_name,
nic
)
nic_info = async_nic_update.result()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment