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
In this quickstart, you'll learn how to use an[Azure libraries (SDK) for Python](https://learn.microsoft.com/azure/developer/python/sdk/azure-sdk-overview?view=azure-python)
17
+
In this quickstart, you'll learn how to use the[Azure libraries (SDK) for Python](https://learn.microsoft.com/azure/developer/python/sdk/azure-sdk-overview?view=azure-python)
18
18
to create an Azure Database for PostgreSQL - Flexible Server.
19
19
20
20
Flexible server is a managed service that you use to run, manage, and scale highly available PostgreSQL databases in the cloud. You can use Python SDK to provision a PostgreSQL Flexible Server, multiple servers or multiple databases on a server.
@@ -26,15 +26,15 @@ An Azure account with an active subscription. [Create one for free](https://azur
26
26
27
27
## Create the Server
28
28
29
-
Install the required packages:
29
+
First, install the required packages:
30
30
31
31
```bash
32
32
pip install azure-mgmt-resource
33
33
pip install azure-identity
34
34
pip install azure-mgmt-rdbms
35
35
```
36
36
37
-
Create a create_postgres_flexible_server.py file and include the following code:
37
+
Create a `create_postgres_flexible_server.py` file and include the following code:
Replace the following placeholders with your data:
92
92
93
-
-**<subscription_id>**:
94
-
-**<resource_group>**: enter your own login account to use when you connect to the server. For example, `myadmin`.
95
-
-**<servername>**: Unique name that identifies your Azure Database for PostgreSQL server. The domain name `postgres.database.azure.com` is appended to the server name you provide. Server name must be at least 3 characters and at most 63 characters. Server name must only contain lowercase letters, numbers, and hyphens.
93
+
-**<subscription_id>**: Your own [subscription id](../../azure-portal/get-subscription-tenant-id.md#find-your-azure-subscription).
94
+
-**<resource_group>**: The name of the resource group you want to use. The script will create a new resource group if it doesn't exist.
95
+
-**<servername>**: A unique name that identifies your Azure Database for PostgreSQL server. The domain name `postgres.database.azure.com` is appended to the server name you provide. The server name must be at least 3 characters and at most 63 characters, and can only contain lowercase letters, numbers, and hyphens.
96
96
-**administrator_login**: The primary administrator username for the server. You can create additional users after the server has been created.
97
-
-**<mySecurePassword>**: Password for the primary administrator for the server. It must contain between 8 and 128 characters. Your password must contain characters from three of the following categories: English uppercase letters, English lowercase letters, numbers (0 through 9), and non-alphanumeric characters (!, $, #, %, etc.).
97
+
-**<mySecurePassword>**: A password for the primary administrator for the server. It must contain between 8 and 128 characters. Your password must contain characters from three of the following categories: English uppercase letters, English lowercase letters, numbers (0 through 9), and non-alphanumeric characters (!, $, #, %, etc.).
98
+
99
+
You can also customize other parameters like location, storage size, engine version, etc.
98
100
99
-
You can also change other parameters like location, storage size, engine version etc.
100
101
101
102
> [!NOTE]
102
103
> Note that the DefaultAzureCredential class will try to authenticate using various methods, such as environment variables, managed identities, or the Azure CLI.
103
104
> Make sure you have one of these methods set up. You can find more information on authentication in the [Azure SDK documentation](https://learn.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential).
104
105
105
106
## Review deployed resources
106
107
107
-
Use the Azure portal, Azure CLI, or Azure PowerShell to validate the deployment and review the deployed resources.
108
+
You can use the Python SDK, Azure portal, Azure CLI, Azure PowerShell, and various other tools to validate the deployment and review the deployed resources. Some examples are provided below.
109
+
110
+
111
+
# [Python SDK](#tab/Python SDK)
112
+
Add the `check_server_created` function to your existing script to use the servers attribute of the `PostgreSQLManagementClient` instance to check if the PostgreSQL Flexible Server was created:
> The `check_server_created` function will return the server state as soon as the server is provisioned. However, it might take a few minutes for the server to become fully available. Ensure that you wait for the server to be in the Ready state before connecting to it.
0 commit comments