  def CreateNetworkInterface(self,
                             name: str,
                             region: Optional[str] = None) -> str:
    """Create a network interface and returns its ID.

    Args:
      name (str): The name of the network interface.
      region (str): Optional. The region in which to create the network
          interface. Default uses default_region of the AZAccount object.

    Returns:
      str: The id of the created network interface.

    Raises:
      ValueError: if name is not provided.
      ResourceCreationError: If no network interface could be created.
    """
    if not name:
      raise ValueError('name must be specified. Provided: {0!s}'.format(name))

    if not region:
      region = self.az_account.default_region

    network_interface_name = '{0:s}-nic'.format(name)
    ip_config_name = '{0:s}-ipconfig'.format(name)

    # Check if the network interface already exists, and returns its ID if so.
    try:
      nic = self.network_client.network_interfaces.get(
          self.az_account.default_resource_group_name, network_interface_name)
      nic_id = nic.id  # type: str
      return nic_id
    except azure_exceptions.ResourceNotFoundError:
      # NIC doesn't exist, ignore the error as we create it later on.
      pass
    except azure_exceptions.AzureError as exception:
      raise errors.ResourceCreationError(
          'Could not create network interface: {0!s}'.format(exception),
          __name__) from exception

    # pylint: disable=unbalanced-tuple-unpacking
    # IP address, virtual network, subnet, network security group
    public_ip, _, subnet, nsg = self._CreateNetworkInterfaceElements(
        name, region=region)
    # pylint: enable=unbalanced-tuple-unpacking

    creation_data = {
        'location': region,
        'ip_configurations': [{
            'name': ip_config_name,
            'public_ip_address': public_ip,
            'subnet': {
                'id': subnet.id
            }
        }],
        'networkSecurityGroup': nsg
    }

    try:
      request = self.network_client.network_interfaces.begin_create_or_update(
          self.az_account.default_resource_group_name,
          network_interface_name,
          creation_data)
      request.wait()
    except azure_exceptions.AzureError as exception:
      raise errors.ResourceCreationError(
          'Could not create network interface: {0!s}'.format(exception),
          __name__) from exception

    network_interface_id = request.result().id  # type: str
    return network_interface_id
Create a network interface and returns its ID.

Args:
name (str): The name of the network interface.
region (str): Optional. The region in which to create the network
interface. Default uses default_region of the AZAccount object.

Returns:
str: The id of the created network interface.

Raises:
ValueError: if name is not provided.
ResourceCreationError: If no network interface could be created.
libcloudforensics/providers/azure/internal/network.py