Skip to content

Commit aaa2351

Browse files
author
Lukas Fittl (MSFT)
authored
MySQL Azure AD Authentication: Fix formatting issue, improve ordering
This fixes a formatting issue for instructions on how to connect using the `mysql` CLI. It also re-orders the page, so that we talk about connecting first, and then about creating users (which requires the reader to have connected).
1 parent aab2cbf commit aaa2351

File tree

1 file changed

+41
-38
lines changed

1 file changed

+41
-38
lines changed

articles/mysql/howto-configure-sign-in-azure-ad-authentication.md

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,42 +35,7 @@ Only one Azure AD admin can be created per MySQL server and selection of another
3535

3636
In a future release we will support specifying an Azure AD group instead of an individual user to have multiple administrators, however this is currently not supported yet.
3737

38-
## Creating Azure AD users in Azure Database for MySQL
39-
40-
To add an Azure AD user to your Azure Database for MySQL database, perform the following steps after connecting (see later section on how to connect):
41-
42-
1. First ensure that the Azure AD user `<user>@yourtenant.onmicrosoft.com` is a valid user in Azure AD tenant.
43-
2. Sign in to your Azure Database for MySQL instance as the Azure AD Admin user.
44-
3. Create user `<user>@yourtenant.onmicrosoft.com` in Azure Database for MySQL.
45-
46-
**Example:**
47-
48-
```sql
49-
CREATE AADUSER '[email protected]';
50-
```
51-
52-
For user names that exceed 32 characters, it is recommended you use an alias instead, to be used when connecting:
53-
54-
Example:
55-
56-
```sql
57-
CREATE AADUSER '[email protected]' as 'userDefinedShortName';
58-
```
59-
60-
> [!NOTE]
61-
> Authenticating a user through Azure AD does not give the user any permissions to access objects within the Azure Database for MySQL database. You must grant the user the required permissions manually.
62-
63-
## Creating Azure AD groups in Azure Database for MySQL
64-
65-
To enable an Azure AD group for access to your database, use the same mechanism as for users, but instead specify the group name:
66-
67-
**Example:**
68-
69-
```sql
70-
CREATE AADUSER 'Prod_DB_Readonly';
71-
```
72-
73-
When logging in, members of the group will use their personal access tokens, but sign with the group name specified as the username.
38+
After configuring the administrator, you can now sign in:
7439

7540
## Connecting to Azure Database for MySQL using Azure AD
7641

@@ -151,16 +116,54 @@ When connecting you need to use the access token as the MySQL user password. Whe
151116
When using the CLI, you can use this short-hand to connect:
152117

153118
**Example (Linux/macOS):**
154-
119+
```
155120
mysql -h mydb.mysql.database.azure.com \
156121
--user [email protected]@mydb \
157122
--enable-cleartext-plugin \
158-
--password=`az account get-access-token --resource-type oss-rdbms --output tsv --query accessToken`
123+
--password=`az account get-access-token --resource-type oss-rdbms --output tsv --query accessToken`
124+
```
159125

160126
Note the “enable-cleartext-plugin” setting – you need to use a similar configuration with other clients to make sure the token gets sent to the server without being hashed.
161127

162128
You are now authenticated to your MySQL server using Azure AD authentication.
163129

130+
## Creating Azure AD users in Azure Database for MySQL
131+
132+
To add an Azure AD user to your Azure Database for MySQL database, perform the following steps after connecting (see later section on how to connect):
133+
134+
1. First ensure that the Azure AD user `<user>@yourtenant.onmicrosoft.com` is a valid user in Azure AD tenant.
135+
2. Sign in to your Azure Database for MySQL instance as the Azure AD Admin user.
136+
3. Create user `<user>@yourtenant.onmicrosoft.com` in Azure Database for MySQL.
137+
138+
**Example:**
139+
140+
```sql
141+
CREATE AADUSER '[email protected]';
142+
```
143+
144+
For user names that exceed 32 characters, it is recommended you use an alias instead, to be used when connecting:
145+
146+
Example:
147+
148+
```sql
149+
CREATE AADUSER '[email protected]' as 'userDefinedShortName';
150+
```
151+
152+
> [!NOTE]
153+
> Authenticating a user through Azure AD does not give the user any permissions to access objects within the Azure Database for MySQL database. You must grant the user the required permissions manually.
154+
155+
## Creating Azure AD groups in Azure Database for MySQL
156+
157+
To enable an Azure AD group for access to your database, use the same mechanism as for users, but instead specify the group name:
158+
159+
**Example:**
160+
161+
```sql
162+
CREATE AADUSER 'Prod_DB_Readonly';
163+
```
164+
165+
When logging in, members of the group will use their personal access tokens, but sign with the group name specified as the username.
166+
164167
## Token Validation
165168

166169
Azure AD authentication in Azure Database for MySQL ensures that the user exists in the MySQL server, and it checks the validity of the token by validating the contents of the token. The following token validation steps are performed:

0 commit comments

Comments
 (0)