You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can automatically deploy your database updates to Azure Database for PostgreSQL Flexible Server after every successful build with **Azure Pipelines**. You can use Azure CLI task to update the database either with a SQL file or an inline SQL script against the database. This task can be run on cross-platform agents running on Linux, macOS, or Windows operating systems.
17
+
You can automatically deploy your database updates to Azure Database for PostgreSQL flexible server after every successful build with **Azure Pipelines**. You can use Azure CLI task to update the database either with a SQL file or an inline SQL script against the database. This task can be run on cross-platform agents running on Linux, macOS, or Windows operating systems.
18
18
19
19
## Prerequisites
20
20
21
21
- An Azure account. If you don't have one, [get a free trial](https://azure.microsoft.com/free/).
22
22
-[Azure Resource Manager service connection](/azure/devops/pipelines/library/connect-to-azure) to your Azure account
23
-
- Microsoft hosted agents have Azure CLI pre-installed. However if you are using private agents, [install Azure CLI](/cli/azure/install-azure-cli) on the computer(s) that run the build and release agent. If an agent is already running on the machine on which the Azure CLI is installed, restart the agent to ensure all the relevant stage variables are updated.
24
-
- Create an Azure Database for PostgreSQL Flexible Server using [Azure portal](./quickstart-create-server-portal.md) or [Azure CLI](./quickstart-create-server-cli.md)
23
+
- Microsoft hosted agents have Azure CLI preinstalled. However if you are using private agents, [install Azure CLI](/cli/azure/install-azure-cli) on the computer(s) that run the build and release agent. If an agent is already running on the machine on which the Azure CLI is installed, restart the agent to ensure all the relevant stage variables are updated.
24
+
- Create an Azure Database for PostgreSQL flexible server instance using the[Azure portal](./quickstart-create-server-portal.md) or [Azure CLI](./quickstart-create-server-cli.md)
25
25
26
26
27
27
## Use SQL file
28
28
29
-
The following example illustrates how to pass database arguments and run ```execute``` command
29
+
The following example illustrates how to pass database arguments and run `execute` command
30
30
31
31
```yaml
32
32
- task: AzureCLI@2
@@ -48,7 +48,7 @@ The following example illustrates how to pass database arguments and run ```exec
48
48
49
49
## Use inline SQL script
50
50
51
-
The following example illustrates how to run an inline SQL script using ```execute``` command.
51
+
The following example illustrates how to run an inline SQL script using `execute` command.
52
52
53
53
```yaml
54
54
- task: AzureCLI@2
@@ -76,11 +76,11 @@ You can see the full list of all the task inputs when using Azure CLI task with
76
76
| Parameter | Description |
77
77
| :------------------- | :-------------------|
78
78
| azureSubscription| (Required) Provide the Azure Resource Manager subscription for the deployment. This parameter is shown only when the selected task version is 0.* as Azure CLI task v1.0 supports only Azure Resource Manager subscriptions. |
79
-
|scriptType| (Required) Provide the type of script. Supported scripts are PowerShell, PowerShell Core, Bat, Shell, and script. When running on a **Linux agent**, select one of the following: ```bash``` or ```pscore``` . When running **Windows agent**, select one of the following: ```batch```,```ps``` and ```pscore```. |
80
-
|scriptLocation| (Required) Provide the path to script, for example real file path or use ```Inline script``` when providing the scripts inline. The default value is ```scriptPath```. |
79
+
|scriptType| (Required) Provide the type of script. Supported scripts are PowerShell, PowerShell Core, Bat, Shell, and script. When running on a **Linux agent**, select one of the following: `bash` or `pscore` . When running **Windows agent**, select one of the following: `batch`,`ps` and `pscore`. |
80
+
|scriptLocation| (Required) Provide the path to script, for example real file path or use `Inline script` when providing the scripts inline. The default value is `scriptPath`. |
81
81
|scriptPath| (Required) Fully qualified path of the script(.ps1 or .bat or .cmd when using Windows-based agent else <code>.ps1 </code> or <code>.sh </code> when using linux-based agent) or a path relative to the default working directory. |
82
-
|inlineScript|(Required) You can write your scripts inline here. When using Windows agent, use PowerShell or PowerShell Core or batch scripting whereas use PowerShell Core or shell scripting when using Linux-based agents. For batch files use the prefix \"call\" before every Azure command. You can also pass predefined and custom variables to this script using arguments. <br/>Example for PowerShell/PowerShellCore/shell:``` az --version az account show``` <br/>Example for batch: ``` call az --version call az account show```. |
83
-
| arguments| (Optional) Provide all the arguments passed to the script. For examples ```-SERVERNAME mydemoserver```. |
82
+
|inlineScript|(Required) You can write your scripts inline here. When using Windows agent, use PowerShell or PowerShell Core or batch scripting whereas use PowerShell Core or shell scripting when using Linux-based agents. For batch files use the prefix \"call\" before every Azure command. You can also pass predefined and custom variables to this script using arguments. <br/>Example for PowerShell/PowerShellCore/shell:` az --version az account show` <br/>Example for batch: ` call az --version call az account show`. |
83
+
| arguments| (Optional) Provide all the arguments passed to the script. For examples `-SERVERNAME mydemoserver`. |
84
84
|powerShellErrorActionPreference| (Optional) Prepends the line <b>$ErrorActionPreference = 'VALUE'</b> at the top of your PowerShell/PowerShell Core script. The default value is stop. Supported values are stop, continue, and silentlyContinue. |
85
85
|addSpnToEnvironment|(Optional) Adds service principal ID and key of the Azure endpoint you chose to the script's execution environment. You can use these variables: <b>$env:servicePrincipalId, $env:servicePrincipalKey and $env:tenantId</b> in your script. This is honored only when the Azure endpoint has Service Principal authentication scheme. The default value is false.|
86
86
|useGlobalConfig|(Optional) If this is false, this task will use its own separate <a href= "/cli/azure/azure-cli-configuration#cli-configuration-file">Azure CLI configuration directory</a>. This can be used to run Azure CLI tasks in <b>parallel</b> releases" <br/>Default value: false</td>
@@ -91,7 +91,7 @@ You can see the full list of all the task inputs when using Azure CLI task with
91
91
Having issues with CLI Task, see [how to troubleshoot Build and Release](/azure/devops/pipelines/troubleshooting/troubleshooting).
92
92
93
93
## Next steps
94
-
Here are some related tasks that can be used to deploy with Azure Piplelines.
94
+
Here are some related tasks that can be used to deploy with Azure Pipelines.
95
95
96
96
- [Azure Resource Group Deployment](/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment)
97
97
- [Azure Web App Deployment](/azure/devops/pipelines/tasks/deploy/azure-rm-web-app-deployment)
Audit logging of database activities in Azure Database for PostgreSQL - Flexible Server is available through the PostgreSQL Audit extension: [pgAudit](https://www.pgaudit.org/). pgAudit provides detailed session and/or object audit logging.
17
+
Audit logging of database activities in Azure Database for PostgreSQL flexible server is available through the PostgreSQL Audit extension: [pgAudit](https://www.pgaudit.org/). pgAudit provides detailed session and/or object audit logging.
18
18
19
19
If you want Azure resource-level logs for operations like compute and storage scaling, see the [Azure Activity Log](../../azure-monitor/essentials/platform-logs-overview.md).
20
20
21
21
## Usage considerations
22
-
By default, pgAudit log statements are emitted along with your regular log statements by using Postgres's standard logging facility. In Azure Database for PostgreSQL - Flexible Server, you can configure all logs to be sent to Azure Monitor Log store for later analytics in Log Analytics. If you enable Azure Monitor resource logging, your logs will be automatically sent (in JSON format) to Azure Storage, Event Hubs, and/or Azure Monitor logs, depending on your choice.
22
+
By default, pgAudit log statements are emitted along with your regular log statements by using Postgres's standard logging facility. In Azure Database for PostgreSQL flexible server, you can configure all logs to be sent to Azure Monitor Log store for later analytics in Log Analytics. If you enable Azure Monitor resource logging, your logs will be automatically sent (in JSON format) to Azure Storage, Event Hubs, and/or Azure Monitor logs, depending on your choice.
23
23
24
24
To learn how to set up logging to Azure Storage, Event Hubs, or Azure Monitor logs, visit the resource logs section of the [server logs article](concepts-logging.md).
25
25
26
26
## Installing pgAudit
27
-
Before you can install pgAudit extension in Azure Database for PostgreSQL - Flexible Server, you will need to allow-list pgAudit extension for use.
27
+
Before you can install pgAudit extension in Azure Database for PostgreSQL flexible server, you need to allow-list pgAudit extension for use.
28
28
29
29
Using the [Azure portal](https://portal.azure.com):
30
30
31
-
1. Select your Azure Database for PostgreSQL - Flexible Server.
31
+
1. Select your Azure Database for PostgreSQL flexible server instance.
32
32
2. On the sidebar, select **Server Parameters**.
33
33
3. Search for the `azure.extensions` parameter.
34
34
4. Select pgAudit as extension you wish to allow-list.
35
-
:::image type="content" source="./media/concepts-extensions/allow-list.png" alt-text="Screenshot showing Azure Database for PostgreSQL - allow-listing extensions for installation":::
35
+
:::image type="content" source="./media/concepts-extensions/allow-list.png" alt-text="Screenshot showing Azure Database for PostgreSQL - allow-listing extensions for installation.":::
36
36
37
37
Using [Azure CLI](/cli/azure/):
38
38
39
-
You can allow-list extensions via CLI parameter set [command](/cli/azure/postgres/flexible-server/parameter?view=azure-cli-latest&preserve-view=true).
39
+
You can allow-list extensions via CLI parameter set [command](/cli/azure/postgres/flexible-server/parameter).
40
40
41
41
```bash
42
42
az postgres flexible-server parameter set --resource-group <your resource group> --server-name <your server name> --subscription <your subscription id> --name azure.extensions --value pgAudit
@@ -47,18 +47,18 @@ To install pgAudit, you need to include it in the server's shared preload librar
47
47
48
48
Using the [Azure portal](https://portal.azure.com):
49
49
50
-
1. Select your Azure Database for PostgreSQL - Flexible Server.
50
+
1. Select your Azure Database for PostgreSQL flexible server instance.
51
51
2. On the sidebar, select **Server Parameters**.
52
52
3. Search for the `shared_preload_libraries` parameter.
53
53
4. Select **pgaudit**.
54
-
:::image type="content" source="./media/concepts-audit/shared-preload-libraries.png" alt-text="Screenshot showing Azure Database for PostgreSQL - enabling shared_preload_libraries for pgaudit":::
54
+
:::image type="content" source="./media/concepts-audit/shared-preload-libraries.png" alt-text="Screenshot showing Azure Database for PostgreSQL flexible server enabling shared_preload_libraries for pgaudit.":::
55
55
5. You can check that **pgaudit** is loaded in shared_preload_libraries by executing following query in psql:
56
56
```SQL
57
57
show shared_preload_libraries;
58
58
```
59
-
You should see **pgaudit**in the query result that will return shared_preload_libraries
59
+
You should see **pgaudit**in the query result that will return shared_preload_libraries.
60
60
61
-
6. Connect to your server using a client (like psql) and enable the pgAudit extension
61
+
6. Connect to your server using a client (like psql) and enable the pgAudit extension.
62
62
```SQL
63
63
CREATE EXTENSION pgaudit;
64
64
```
@@ -92,7 +92,7 @@ The [pgAudit documentation](https://github.com/pgaudit/pgaudit/blob/master/READM
92
92
>`pgaudit.log_level` is only enabled when `pgaudit.log_client` is on.
93
93
94
94
> [!NOTE]
95
-
>In Azure Database for PostgreSQL - Flexible Server, `pgaudit.log`cannot be set using a `-` (minus) sign shortcut as described in the pgAudit documentation. All required statement classes (READ, WRITE, etc.) should be individually specified.
95
+
>In Azure Database for PostgreSQL flexible server `pgaudit.log`can't be set using a `-` (minus) sign shortcut as described in the pgAudit documentation. All required statement classes (READ, WRITE, etc.) should be individually specified.
96
96
> [!NOTE]
97
97
>If you set the log_statement parameter to DDL or ALL, and run a `CREATE ROLE/USER ... WITH PASSWORD ... ; ` or `ALTER ROLE/USER ... WITH PASSWORD ... ;`, command, then PostgreSQL creates an entry in the PostgreSQL logs, where password is logged in clear text, which may cause a potential security risk. This is expected behavior as per PostgreSQL engine design. You can, however, use PGAudit extension and set `pgaudit.log='DDL'` parameter in server parameters page, which doesn't record any `CREATE/ALTER ROLE` statement in Postgres Log, unlike Postgres `log_statement='DDL'` setting. If you do need to log these statements you can add `pgaudit.log ='ROLE'`in addition, which, while logging `'CREATE/ALTER ROLE'` will redact the password from logs.
98
98
@@ -122,5 +122,5 @@ AzureDiagnostics
122
122
123
123
124
124
## Next steps
125
-
- [Learn about logging in Azure Database for PostgreSQL - Flexible Server](concepts-logging.md)
126
-
- [Learn how to setup logging in Azure Database for PostgreSQL - Flexible Server and how to access logs](howto-configure-and-access-logs.md)
125
+
- [Learn about logging in Azure Database for PostgreSQL flexible server](concepts-logging.md)
126
+
- [Learn how to setup logging in Azure Database for PostgreSQL flexible serverand how to access logs](howto-configure-and-access-logs.md)
0 commit comments