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 create a [service principal](../../active-directory/develop/app-objects-and-service-principals.md) with the [az ad sp create-for-rbac](/cli/azure/ad/sp#az-ad-sp-create-for-rbac&preserve-view=true) command in the [Azure CLI](/cli/azure/). Run this command with [Azure Cloud Shell](https://shell.azure.com/) in the Azure portal or by selecting the **Try it** button.
44
-
45
-
Replace the placeholders `server-name` with the name of your PostgreSQL server hosted on Azure. Replace the `subscription-id` and `resource-group` with the subscription ID and resource group connected to your PostgreSQL server.
46
-
47
-
```azurecli-interactive
48
-
az ad sp create-for-rbac --name {server-name} --role contributor \
The output is a JSON object with the role assignment credentials that provide access to your database similar to below. Copy this output JSON object for later.
54
-
55
-
```output
56
-
{
57
-
"clientId": "<GUID>",
58
-
"clientSecret": "<GUID>",
59
-
"subscriptionId": "<GUID>",
60
-
"tenantId": "<GUID>",
61
-
(...)
62
-
}
63
-
```
64
-
65
-
> [!IMPORTANT]
66
-
> It is always a good practice to grant minimum access. The scope in the previous example is limited to the specific server and not the entire resource group.
@@ -112,21 +73,23 @@ You will use the connection string as a GitHub secret.
112
73
113
74
on:
114
75
push:
115
-
branches: [ master ]
76
+
branches: [ main ]
116
77
pull_request:
117
-
branches: [ master ]
78
+
branches: [ main ]
118
79
```
119
80
120
-
1. Rename your workflow `PostgreSQL for GitHub Actions` and add the checkout and login actions. These actions will checkout your site code and authenticate with Azure using the `AZURE_CREDENTIALS` GitHub secret you created earlier.
81
+
1. Rename your workflow `PostgreSQL for GitHub Actions` and add the checkout and login actions. These actions will checkout your site code and authenticate with Azure using the GitHub secret(s) you created earlier.
82
+
83
+
# [Service principal](#tab/userlevel)
121
84
122
85
```yaml
123
86
name: PostgreSQL for GitHub Actions
124
87
125
88
on:
126
89
push:
127
-
branches: [ master ]
90
+
branches: [ main ]
128
91
pull_request:
129
-
branches: [ master ]
92
+
branches: [ main ]
130
93
131
94
jobs:
132
95
build:
@@ -137,6 +100,29 @@ You will use the connection string as a GitHub secret.
2. Use the Azure PostgreSQL Deploy action to connect to your PostgreSQL instance. Replace `POSTGRESQL_SERVER_NAME` with the name of your server. You should have a PostgreSQL data file named `data.sql` at the root level of your repository.
142
128
@@ -150,14 +136,16 @@ You will use the connection string as a GitHub secret.
150
136
151
137
3. Complete your workflow by adding an action to logout of Azure. Here is the completed workflow. The file will appear in the `.github/workflows` folder of your repository.
152
138
139
+
# [Service principal](#tab/userlevel)
140
+
153
141
```yaml
154
142
name: PostgreSQL for GitHub Actions
155
143
156
144
on:
157
145
push:
158
-
branches: [ master ]
146
+
branches: [ main ]
159
147
pull_request:
160
-
branches: [ master ]
148
+
branches: [ main ]
161
149
162
150
163
151
jobs:
@@ -167,7 +155,42 @@ You will use the connection string as a GitHub secret.
0 commit comments