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
Copy file name to clipboardExpand all lines: samples/features/security/azure-active-directory-auth/token/README.md
+22-21Lines changed: 22 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,39 +8,40 @@
8
8
9
9
## About this sample
10
10
11
-
The Token project contains a simple console application that connects to Azure SQL database using a self-signed certificate.
11
+
The Token project contains a simple console application that connects to Azure SQL Database using a self-signed certificate.
12
12
13
13
**Software prerequisites:**
14
14
15
15
1. The `makecert.exe` utility, which is included in the Windows SDK
16
16
+ It is sometimes included in Visual Studio installations (depending on the selections made during installation). A search of your machine for `makecert.exe` would provide verification that the Windows SDK was installed.
17
-
+ If the Windows SDK was not installed, you may [download it here](http://msdn.microsoft.com/en-US/windows/desktop/aa904949)
17
+
+ If the Windows SDK was not installed, you may [download it here](https://learn.microsoft.com/windows/apps/windows-app-sdk/downloads)
18
18
+ You can learn more about the `makecert.exe` [utility here](https://msdn.microsoft.com/library/windows/desktop/aa386968.aspx)
19
19
2. PowerShell with Azure Active Directory Module
20
-
+ To download the latest PowerShell version [see this page](https://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/#Install)
21
-
+ [Install the Azure AD PowerShell Module](https://msdn.microsoft.com/en-us/library/azure/jj151815.aspx), if it is not already installed in your client machine.
20
+
+ To download the latest PowerShell version [see this page](https://azure.microsoft.com/documentation/articles/powershell-install-configure/#Install)
21
+
+ [Install the Microsoft Entra ID PowerShell Module](https://msdn.microsoft.com/en-us/library/azure/jj151815.aspx), if it is not already installed in your client machine.
22
22
23
23
<aname=run-this-sample></a>
24
24
## Run this sample
25
25
26
-
1. Create an application account in Azure AD for your service.
26
+
1. Create an application account in Microsoft Entra ID for your service.
27
27
- Sign in to the Azure management portal.
28
28
- Click on Azure Active Directory in the left hand navigation
29
29
- Click the directory tenant where you wish to register the sample application. This must be the same directory that is associated with your database (the server hosting your database).
30
30
- Click the Applications tab
31
31
- In the drawer, click Add.
32
32
- Click "Add an application my organization is developing".
33
33
- Enter mytokentest as a friendly name for the application, select "Web Application and/or Web API", and click next.
34
-
- Assuming this application is a daemon/service and not a web application, it doesn't have a sign-in URL or app ID URI. For these two fields, enter http://mytokentest
35
-
- While still in the Azure portal, click the Configure tab of your application.
36
-
- Find the Client ID value and copy it into a text editor, you will need this later when configuring your application ( i.e. a4bbfe26-dbaa-4fec-8ef5-223d229f647d /see the snapshot below/)
37
-

34
+
- Assuming this application is a daemon/service and not a web application, it doesn't have a sign-in URL or app ID URI. For these two fields, enter `http://mytokentest`
35
+
- While still in the Azure portal, select Configure in your application.
36
+
- Find the Client ID value and copy it into a text editor, you will need this later when configuring your application
38
37
39
-
2. Logon to your Azure SQL Server’s user database as an Azure AD admin and using a T-SQL command provision a contained database user for your application principal:
38
+

39
+
40
+
2. Logon to your Azure SQL Server’s user database as an Microsoft Entra ID admin and using a T-SQL command provision a contained database user for your application principal:
40
41
```sql
41
42
CREATE USER [mytokentest] FROM EXTERNAL PROVIDER
42
43
```
43
-
- [See this link](https://azure.microsoft.com/en-us/documentation/articles/sql-database-aad-authentication/) for more details on how to create an Azure Ad admin and a contained database user.
44
+
- [See this link](https://azure.microsoft.com/documentation/articles/sql-database-aad-authentication/) for more details on how to create an Microsoft Entra ID admin and a contained database user.
44
45
45
46
3. On the machine you are going to run the project on, generate and install a self-signed certificate.
46
47
- To complete this step, you will need to use `Makecert.exe`
@@ -53,10 +54,10 @@ The Token project contains a simple console application that connects to Azure S
4. Add the certificate as a key for the application you created in Azure AD.
57
-
- Click the Microsoft Azure Active Directory Module for Windows PowerShell shortcut on desktop to open a Windows PowerShell workspace that has the Azure AD cmdlets.
57
+
4. Add the certificate as a key for the application you created in Microsoft Entra ID.
58
+
- Click the Microsoft Azure Active Directory Module for Windows PowerShell shortcut on desktop to open a Windows PowerShell workspace that has the Microsoft Entra ID cmdlets.
58
59
- Copy the following code snippet to a text editor.
59
-
- `connect-msolservice` will ask for you Azure AD credentials. Please be sure to use credentials that are part of Azure AD global admin to connect and to proceed with the scripts below.
60
+
- `connect-msolservice` will ask for you Microsoft Entra ID credentials. Please be sure to use credentials that are part of Microsoft Entra ID global admin to connect and to proceed with the scripts below.
60
61
```
61
62
connect-msolservice
62
63
@@ -74,23 +75,23 @@ The Token project contains a simple console application that connects to Azure S
74
75
75
76
5. Configure the certificate and your application account in the *app.config* file in the project.
76
77
+ In Visual Studio, open *app.config* in the Solution Explorer
- Find the app key `ida:Tenant` and replace the value with your AAD tenant name (your AAD domain)
79
80
- Find the app key `ida:ClientID` and replace the value with the Client ID for the application registration from the Azure Portal (the value from step 1).
80
81
- Find the app key `ida:Cert_Name` and replace the value with the subject name (CN) of the self-signed certificate you created
81
82
- For example:
82
83
```csharp
83
-
<add key="ida:Tenant" value="cqclinic.onmicrosoft.com" /> //this is the AAD domain
84
-
<add key="ida:ClientId" value="a4bbfe26-dbaa-4fec-8ef5-223d229f647d"/> //this is the Client ID
84
+
<add key="ida:Tenant" value="<tenant name>" /> //this is the domain
85
+
<add key="ida:ClientId" value="<client id>"/> //this is the Client ID
85
86
<add key="ida:CertName" value="CN=mytokentestCert"/> //this is the Cert_name use by makecert.exe
86
87
```
87
88
+ In Visual Studio, open *Program.cs* in the Solution Explorer
88
-

89
+

89
90
- Make the following changes:
90
91
```csharp
91
-
builder["Data Source"] = "aad-managed-demo.database.windows.net"; // replace with your server name
92
+
builder["Data Source"] = "<servername>.database.windows.net"; // replace with your server name
92
93
builder["Initial Catalog"] = "demo"; // replace with your database name
93
94
```
94
-
6. Run the demo. (Click*Run* or press *F5*)
95
+
6. Run the demo. (Select*Run* or press *F5*)
95
96
+ A successful authorization should result in a message that states "Connected to the database" similar to the following:
0 commit comments