title: Is it possible to create an Azure VM with open port through Azure API?
body: <p>I am creating a VM using the following API:  </p>
  
  <blockquote>
    <p><code>https://management.azure.com/subscriptions/{{subscription-id}}/resourceGroups/{{resourceGroupName}}/providers/Microsoft.Compute/virtualMachines/{{vmName}}?api-version=2017-12-01</code></p>
  </blockquote>
  
  <p>Body:</p>
  
  <pre><code>{
    "location": "westus",
    "properties": {
      "hardwareProfile": {
        "vmSize": "Standard_D1_v2"
      },
      "storageProfile": {
        "imageReference": {
          "sku": "2016-Datacenter",
          "publisher": "MicrosoftWindowsServer",
          "version": "latest",
          "offer": "WindowsServer"
        },
        "osDisk": {
          "caching": "ReadWrite",
          "managedDisk": {
            "storageAccountType": "Standard_LRS"
          },
          "name": "myVMosdisk",
          "createOption": "FromImage"
        }
      },
      "osProfile": {
        "adminUsername": "{your-username}",
        "computerName": "myVM",
        "adminPassword": "{your-password}"
      },
      "networkProfile": {
        "networkInterfaces": [
          {
            "id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
            "properties": {
              "primary": true
            }
          }
        ]
      }
    }
  }
  </code></pre>
  
  <p>Then, I have to run a command to open a port to my VM:</p>
  
  <pre><code>az vm open-port --resource-group "my-rg" --name "my-vm" --port 3389
  </code></pre>
  
  <p>I was wondering if is it possible to include it in my json when I am sending the request, so I wouldn't need to perform the action to open a port through a command-line tool.</p>