> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/public-exposure/appsec2-azure-42.md).

# Azure PostgreSQL servers not configured with private endpoint misconfiguration detected in code

## Rule Details

|                        |                                      |
| ---------------------- | ------------------------------------ |
| Cortex AppSec Rule ID  | APPSEC2\_AZURE\_42                   |
| Category - Subcategory | Public Exposure - VPC VCN VNet       |
| Provider               | AZURE                                |
| Severity               | MEDIUM                               |
| Framework              | Terraform, Terraform Plan            |
| Mapped CSPM/KSPM Rule  | 0a2feecd-80f9-47f8-9cfc-6d54d4463298 |

## Impact

This rule checks whether Azure PostgreSQL database servers are configured with private endpoints. Private endpoint connections are crucial for ensuring secure communication, as they establish exclusive, private connectivity to Azure Database for PostgreSQL. Configuring a private endpoint restricts access to traffic originating from known networks, preventing entry from potentially malicious or unknown IP addresses, including those within Azure. It is recommended to establish a private endpoint to ensure secure communication for your Azure PostgreSQL database.

## How to Fix

*Resource:* azurerm\_postgresql\_server, azurerm\_private\_endpoint

* *Arguments:* private\_connection\_resource\_id

To fix this issue and establish secure communication with your network, configure your Azure PostgreSQL Server with a private endpoint.

## This code enhances security by establishing a private endpoint for the PostgreSQL server, restricting access to specific networks and eliminating exposure to the public internet, thereby reducing the risk of potential attacks. The private endpoint uses a private IP address from your VNet, integrating the service into your VNet. All traffic to the service is routed through the private endpoint, eliminating the need for gateways, NAT devices, or encrypted Express Route or VPN connections. \[source,go]

resource "azurerm\_private\_endpoint" "example" { name = "postgresqlprivateendpoint" location = azurerm\_resource\_group.example.location resource\_group\_name = azurerm\_resource\_group.example.name subnet\_id = azure\_subnet.example.id

## private\_service\_connection { name = "postgresqlprivateserviceconnection" private\_connection\_resource\_id = azurerm\_postgresql\_server.example.id subresource\_name = "postgresqlServer" is\_manual\_connection = false } }


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/public-exposure/appsec2-azure-42.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
