diff --git a/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py b/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py index 453ea3a54c..7b8f50eff6 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_networkinterface.py @@ -499,9 +499,13 @@ class AzureRMNetworkInterface(AzureRMModuleBase): if changed: if self.state == 'present': - subnet = self.get_subnet(virtual_network_resource_group, virtual_network_name, self.subnet_name) - if not subnet: - self.fail('subnet {0} is not exist'.format(self.subnet_name)) + subnet = self.network_models.SubResource( + '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/virtualNetworks/{2}/subnets/{3}'.format( + self.subscription_id, + virtual_network_resource_group, + virtual_network_name, + self.subnet_name)) + nic_ip_configurations = [ self.network_models.NetworkInterfaceIPConfiguration( private_ip_allocation_method=ip_config.get('private_ip_allocation_method'), @@ -573,13 +577,6 @@ class AzureRMNetworkInterface(AzureRMModuleBase): except Exception as exc: return None - def get_subnet(self, resource_group, vnet_name, subnet_name): - self.log("Fetching subnet {0} in virtual network {1}".format(subnet_name, vnet_name)) - try: - return self.network_client.subnets.get(resource_group, vnet_name, subnet_name) - except Exception as exc: - return None - def get_security_group(self, name): self.log("Fetching security group {0}".format(name)) try: