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: extensions/README.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -11,8 +11,8 @@ The extensions below explore advanced features of AKS (Kubernetes) and additiona
11
11
12
12
-[Access Azure SQL using **Managed Identity for Azure Resources**](./use-pod-identity-mid)
13
13
14
-
In this sub-project, the Claims Web API application uses an Azure *Managed Identity* to access the Azure SQL Database. [Managed Identities for Azure Resources](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview) is a feature of Azure Active Directory. With Managed Identity, applications deployed on Azure service instances can securely access other Azure resources that support AD authentication. Most importantly, applications do not have to store any credential information. This project also makes use of [AAD Pod Identity](https://github.com/Azure/aad-pod-identity).
14
+
In this sub-project, the Claims Web API application uses an Azure **Managed Identity** to access the Azure SQL Database. [Managed Identities for Azure Resources](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview) is a feature of Azure Active Directory. With Managed Identity, applications deployed on Azure PaaS Services can securely access other Azure resources that support AD authentication. Most importantly, the applications do not have to store any credential information. This project extension also makes use of [AAD Pod Identity](https://github.com/Azure/aad-pod-identity).
15
15
16
-
-[Explore advanced features of **Istio** Service Mesh](./istio-service-mesh)
16
+
-[Explore advanced features of **Istio Service Mesh**](./istio-service-mesh)
17
17
18
18
This sub-project examines the advanced features supported by [Istio Service Mesh](https://istio.io/docs/concepts/what-is-istio/). Features such as intelligent request/traffic routing, traffic splitting (a.k.a Canary rollouts), request timeouts, circuit breaking, fault injection, secure intra-pod communication, rate limiting and others are explored in greater depth and detail.
Copy file name to clipboardExpand all lines: extensions/use-pod-identity-mid/README.md
+77-35Lines changed: 77 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,16 @@
1
-
# Use AAD Pod Identity and Azure Managed Identity to access Azure SQL Server Database
1
+
# Use Azure Managed Identity and AAD Pod Identity to access Azure SQL Server Database
2
2
3
-
This extension project describes the steps for configuring the Claims Web API application to use **AAD Pod Identity** and **Managed Identity**.
4
-
5
-
*AAD Pod Identity* enables Kubernetes applications to access cloud resources securely using managed identities and service principals. Without any code modifications, containerized applications can access any resource on Azure cloud that uses AAD as an Identity provider.
3
+
This project extension describes the steps for configuring the Claims Web API application to use user-assigned **Managed Identity** to access Azure SQL Database. **AAD Pod Identity** is used to retrieve managed identity service principal token and authenticate with Azure SQL Server.
6
4
7
5
*Managed Identity* makes applications more secure by eliminating secrets such as credentials in connection strings.
8
6
9
-
In this extension project, you will work on completing the following tasks.
7
+
*AAD Pod Identity* enables Kubernetes applications to access cloud resources securely using managed identities and service principals. Without any code modifications, containerized applications can access any resource on Azure cloud that use AAD as an Identity provider.
8
+
9
+
In this sub-project, you will work on completing the following tasks.
10
10
11
-
- Deploy *AAD Pod Identity* components on AKS cluster
12
-
- Configure Azure SQL Database to allow *Managed Identity** access to resources (eg., Tables)
11
+
- Install *AAD Pod Identity* components on AKS cluster
12
+
- Configure Azure SQL Database to allow *Managed Identity* access to resources (eg., Database Tables)
13
+
- Deploy AAD Pod Identity application resoureces on AKS
13
14
- Configure the Claims Web API application to retrieve data from Azure SQL Database Tables using Azure *Managed Identity*
14
15
15
16
**Functional Diagram:**
@@ -107,7 +108,7 @@ Follow the steps below to deploy AAD Pod Identity components and custom resource
107
108
```
108
109
109
110
## B. Configure Azure SQL Database
110
-
**Approx. time to complete this section: 45 minutes**
111
+
**Approx. time to complete this section: 25 minutes**
111
112
112
113
To allow **Managed Identity** access to Azure SQL Database resources (eg., Tables), a managed identity user has to be created in the database and granted specific roles. This would allow the managed identity user to manipulate data in the database tables.
113
114
@@ -139,7 +140,7 @@ To allow **Managed Identity** access to Azure SQL Database resources (eg., Table
139
140
140
141

141
142
142
-
Run the following SQL-Transact commands in the **Query** panel/window. Click **Run**.
143
+
Run the following T-SQL commands in the **Query** panel/window. Click **Run**.
143
144
144
145
```bash
145
146
# IMPORTANT:
@@ -158,12 +159,12 @@ To allow **Managed Identity** access to Azure SQL Database resources (eg., Table
158
159

159
160
160
161
## C. Deploy AAD Pod Identity resoureces on AKS
162
+
**Approx. time to complete this section: 10 minutes**
161
163
162
164
1. Create a new Kubernetes namespace for deploying Claims Web API application;
163
165
164
166
```bash
165
-
# Create a new Kubernetes namespace 'dev-claims-mid' for deploying the Claims Web API application with
166
-
# AAD Pod Identity and Managed Identity
167
+
# Create a new Kubernetes namespace 'dev-claims-mid' for deploying the Claims Web API application
167
168
#
168
169
$ kubectl create namespace dev-claims-mid
169
170
#
@@ -206,52 +207,93 @@ To allow **Managed Identity** access to Azure SQL Database resources (eg., Table
206
207
## E. Deploy the Claims Web API application
207
208
**Approx. time to complete this section: 20 minutes**
208
209
209
-
Execute the steps below to deploy the Claims Web API application on AKS.
210
+
Login to the Linux VM (Bastion Host) via an SSH terminal window. Execute the steps below to deploy the Claims Web API application on AKS.
210
211
211
-
1.Update the Helm chart for the Claims Web API application.
212
+
1.Modify the Claims Web API application configuration file.
212
213
213
-
Update the Helm chart `./claims-api/values.yaml` file by referring to the table below.
214
-
215
-
Parameter Name | Value | Description
216
-
-------------- | ----- | -----------
217
-
image.repository | acr-name.azurecr.io/claims-api | Specify the ACR name and image name for the Claims Web API container image.
218
-
image.tag | latest | Specify the claims-api image tag name.
219
-
kv.secretName | sqldbconn | Specify the name of the Azure Key Vault **secret** containing the Azure SQL Database connection string.
220
-
kv.resourceGroup | resource-group | Specify the name of the resource group containing the Azure Key Vault.
221
-
kv.subscriptionId | subscription-id | Specify the Azure subscription in which the Key Vault is provisioned.
222
-
kv.tenantId | tenant-id | Specify the AAD Tenant in which the Key Vault is provisioned.
214
+
Copy `./appsettings.json` file to the project root (**parent**) directory. View the contents of this application configuration file and you will notice that the Azure SQL Connection String (**SqlServerDb**) doesn't have the DB username or password. See below.
223
215
224
216
```bash
225
-
# (If you have not already) Switch to the 'use-pod-identity' extension directory.
226
-
$ cd ./extensions/use-pod-identity
217
+
# 'appsettings.json' file contents
227
218
#
228
-
# Edit the './claims-api/values.yaml` file by referring to the table above.
**Add** this file to the local git repository on the Linux VM.
226
+
227
+
2. Modify Claims Web API application (code).
228
+
229
+
Update the Entity Framework database context class to retrieve the access token for Azure SQL Database. In the project root (**parent**) directory, edit class `./Models/ClaimsContext.cs`. Uncomment the two lines (lines: 5 and 6) as shown in the code snippet below.
**Add** this class to the local git repository on the Linux VM.
241
+
242
+
**Commit** the updated files to your local git repository. Finally, **Push** the local updates to your GitHub repository (your forked repo.).
243
+
244
+
3. Define and execute an Build Pipeline in Azure DevOps.
245
+
246
+
Login to [Azure DevOps Services](https://dev.azure.com/) and define a simple *Pipeline*. This pipeline should contain 2 tasks as detailed below.
247
+
248
+
- Docker **Build** Task: This task builds the Claims Web API application and application container image.
249
+
- Docker **Push** Task: This task pushes the built application container image to ACR.
250
+
251
+
252
+
4. Update the Kubernetes deployment manifest.
253
+
254
+
Log back into the Linux VM.
255
+
256
+
Switch to the extensions directory `./extensions/use-pod-identity-mid`. Edit the Kubernetes application deployment manifest `./k8s-resources/deployment.yaml`. Update this file and specify correct values for attributes listed in the table below.
257
+
258
+
| Attribute Name | Description |
259
+
| -------------- | ----------- |
260
+
acr-name | Name of the Azure Container Registry instance |
261
+
tag-name | Azure DevOps Pipeline **Build ID**. Get the latest build ID from ACR. |
262
+
263
+
In case you have deployed an Ingress Controller (Nginx / Traefik) on the AKS cluster, you can also expose the API endpoint on the ingress controller by defining and deploying an *Ingress* resource (left as an exercise).
264
+
265
+
5. Create a new Kubernetes namespace for deploying Claims Web API with Managed Identity.
233
266
234
267
```bash
235
-
# Use Helm to install the Claims Web API application in namespace 'dev-claims-podid'
Retrieve the Public IP address of the Nginx ingress controller. See the command snippet below.
246
-
247
289
```bash
248
-
# Get the ALB IP address for the Nginx Ingress Controller service.
290
+
# Get the ALB IP address for the Claims Web API endpoint
249
291
# The ALB Public IP address should be listed under column 'EXTERNAL-IP' in the command output.
250
292
#
251
-
$ kubectl get svc -n ingress-basic
293
+
$ kubectl get svc -n dev-claims-mid
252
294
#
253
295
```
254
296
255
297
Access the Claims Web API service using a browser eg., http://[ALB Public IP]/api/v1/claims.
256
298
257
-
Congrats! In this extension, you installed Azure **FlexVolume** driver and **AAD Pod Identity** components. Finally, you configured the Claims Web API application to use FlexVolume driver and the managed Pod Identity to retrieve SQL Connection String from an Azure Key Vault.
299
+
Congrats! In this extension, you installed **AAD Pod Identity** components on the AKS Cluster. You then configured the Claims Web API application to retrieve an OAuth token from Azure AD using **Managed Identity**. This token was used by the application to authenticate to Azure SQL Server. Finally, you deployed the application on AKS and verified the application is able to retrieve and send Claims documents to the SQL Database.
0 commit comments