VMware NSX

vCloud API creating new NAT rules on NSX-T - ApplicationPortProfile not working

  • 1.  vCloud API creating new NAT rules on NSX-T - ApplicationPortProfile not working

    Posted Jan 12, 2025 08:03 AM

    Hi,
    I created a script that takes a CSV file and creates DNAT and SNAT rules in vCloud Director on the NSX-T Edge. SNAT works without issues, DNAT rules that do have an applicationPortProfile work as well, but when the applicationPortProfile should be ANY, I can't get it to work.

    Normally the JSON I send when a ApplicationPortProfile is used looks like this:

    {
      "logging": true,
      "type": "DNAT",
      "name": "GabeTest",
      "description": "Test Rule",
      "dnatExternalPort": "any",
      "applicationPortProfile": {
        "name": "LDAP-tcp-636",
        "id": "urn:vcloud:applicationPortProfile:ede2c52a-xxxxxx"
      },
      "firewallMatch": "MATCH_EXTERNAL_ADDRESS",
      "enabled": true,
      "externalAddresses": "92.xx.xx.xx",
      "internalAddresses": "192.xx.xx.xx"
    }

    That works fine.

    But for "ANY", I can't seem to find the correct way to create the JSON. When I leave out ApplicationPortProfile completely, the API accepts my command, but in vCloud Director I get an error creating the rule:

    [ fbd0158b-xxxxxxxx ] Bad Request: Error occurred in the backing network provider: Field level validation errors: {value 'any' of property translated_ports violates format 'port-or-range'}, error code 255

    I tried several options with the applicationportprofile, leaving the fields in it, but empty or setting to $null, but nothing works. Last resort is to create an ANY application group but I don't think that is the way to do it.

    When I create such a rule manually and then read the rule from the api, it looks like this in vscode (powershell):

    I have no idea how to address this, any tip is welcome