# Approving a private endpoint connection with Azure CLI

- URL: https://baeke.info/2021/06/24/approving-a-private-endpoint-connection-with-azure-cli/
- Author: Geert Baeke
- Published: June 24, 2021
- Topics: automation, azure, azure, cli, networking, privateendpoint, privatelink

In my [previous post](https://baeke.info/2021/06/22/azure-app-services-with-private-link/), I wrote about App Services with Private Link and used Azure Front Door to publish the web app. Azure Front Door Premium (in preview), can create a Private Endpoint and link it to your web app via Azure Private Link. When that happens, you need to approve the pending connection in Private Link Center.

![](https://baeke.info/_astro/2021-06-image-11.DosbFucw_tHIWz.webp)

*The pending connection would be shown here, ready for approval*

Although this is easy to do, you might want to automate this approval. Automation is possible via a REST API but it is easier via Azure CLI.

To do so, first list the private endpoint connections of your resource, in my case that is a web app:

```bash
az network private-endpoint-connection list --id /subscriptions/SUBID/resourceGroups/RGNAME/providers/Microsoft.Web/sites/APPSERVICENAME
```

The above command will return all private endpoint connections of the resource. For each connection, you get the following information:

```json
 {
    "id": "PE CONNECTION ID",
    "location": "East US",
    "name": "NAME",
    "properties": {
      "ipAddresses": [],
      "privateEndpoint": {
        "id": "PE ID",
        "resourceGroup": "RESOURCE GROUP NAME OF PE"
      },
      "privateLinkServiceConnectionState": {
        "actionsRequired": "None",
        "description": "Please approve this connection.",
        "status": "Pending"
      },
      "provisioningState": "Pending"
    },
    "resourceGroup": "RESOURCE GROUP NAME OF YOUR RESOURCE",
    "type": "YOUR RESOURCE TYPE"
  }
```

To approve the above connection, use the following command:

```bash
az network private-endpoint-connection approve --id  PE CONNECTION ID --description "Approved"
```

The --id in the approve command refers to the private endpoint connection ID, which looks like below for a web app:

```
/subscriptions/YOUR SUB ID/resourceGroups/YOUR RESOURCE GROUP/providers/Microsoft.Web/sites/YOUR APP SERVICE NAME/privateEndpointConnections/YOUR PRIVATE ENDPOINT CONNECTION NAME
```

After running the above command, the connection should show as approved:

![](https://baeke.info/_astro/2021-06-image-12.DFWC3ZzK_Z1j0TWu.webp)

*Approved private endpoint connection*

When you automate this in a pipeline, you can first list the private endpoint connections of your resource and filter on provisioningState=”Pending” to find the ones you need to approve.

Hope it helps!
