Skip to content

Commit 6ef9962

Browse files
committed
Updated Readme doc
1 parent d9b605a commit 6ef9962

File tree

2 files changed

+79
-37
lines changed

2 files changed

+79
-37
lines changed

extensions/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ The extensions below explore advanced features of AKS (Kubernetes) and additiona
1111

1212
- [Access Azure SQL using **Managed Identity for Azure Resources**](./use-pod-identity-mid)
1313

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).
1515

16-
- [Explore advanced features of **Istio** Service Mesh](./istio-service-mesh)
16+
- [Explore advanced features of **Istio Service Mesh**](./istio-service-mesh)
1717

1818
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.

extensions/use-pod-identity-mid/README.md

Lines changed: 77 additions & 35 deletions
Original file line numberDiff line numberDiff 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
22

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.
64

75
*Managed Identity* makes applications more secure by eliminating secrets such as credentials in connection strings.
86

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.
1010

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
1314
- Configure the Claims Web API application to retrieve data from Azure SQL Database Tables using Azure *Managed Identity*
1415

1516
**Functional Diagram:**
@@ -107,7 +108,7 @@ Follow the steps below to deploy AAD Pod Identity components and custom resource
107108
```
108109

109110
## B. Configure Azure SQL Database
110-
**Approx. time to complete this section: 45 minutes**
111+
**Approx. time to complete this section: 25 minutes**
111112

112113
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.
113114

@@ -139,7 +140,7 @@ To allow **Managed Identity** access to Azure SQL Database resources (eg., Table
139140

140141
![alt tag](./images/B-04.PNG)
141142

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**.
143144

144145
```bash
145146
# IMPORTANT:
@@ -158,12 +159,12 @@ To allow **Managed Identity** access to Azure SQL Database resources (eg., Table
158159
![alt tag](./images/B-05.PNG)
159160

160161
## C. Deploy AAD Pod Identity resoureces on AKS
162+
**Approx. time to complete this section: 10 minutes**
161163

162164
1. Create a new Kubernetes namespace for deploying Claims Web API application;
163165

164166
```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
167168
#
168169
$ kubectl create namespace dev-claims-mid
169170
#
@@ -206,52 +207,93 @@ To allow **Managed Identity** access to Azure SQL Database resources (eg., Table
206207
## E. Deploy the Claims Web API application
207208
**Approx. time to complete this section: 20 minutes**
208209

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.
210211

211-
1. Update the Helm chart for the Claims Web API application.
212+
1. Modify the Claims Web API application configuration file.
212213

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.
223215

224216
```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
227218
#
228-
# Edit the './claims-api/values.yaml` file by referring to the table above.
219+
"ConnectionStrings": {
220+
"SqlServerDb": "Server=tcp:claimsdb.database.windows.net,1433;Database=ClaimsDB;"
221+
}
229222
#
230223
```
231224

232-
2. Deploy the Claims Web API application.
225+
**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.
230+
231+
```cs
232+
// Uncomment lines 5 and 6
233+
//
234+
public ClaimsContext(DbContextOptions<ClaimsContext> options) : base(options) {
235+
var conn = (Microsoft.Data.SqlClient.SqlConnection) Database.GetDbConnection();
236+
conn.AccessToken = (new Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProvider()).GetAccessTokenAsync("https://database.windows.net/").Result;
237+
}
238+
```
239+
240+
**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.
233266

234267
```bash
235-
# Use Helm to install the Claims Web API application in namespace 'dev-claims-podid'
236-
$ helm install ./claims-api/ --namespace dev-claims-podid --name claims-api-podid
268+
# Create a new Kubernetes namespace 'dev-claims-mid' for deploying the Claims Web API application
269+
# with Managed Identity.
270+
#
271+
$ kubectl create namespace dev-claims-mid
272+
#
273+
```
274+
275+
6. Deploy the Claims Web API application.
276+
277+
```bash
278+
# Install the Claims Web API application in namespace 'dev-claims-mid'
279+
#
280+
$ kubectl apply -f ./k8s-resources/deployment.yaml --namespace dev-claims-mid
237281
#
238282
# Verify the Claims Web API pod is running
239-
$ kubectl get pods -n dev-claims-podid
283+
$ kubectl get pods -n dev-claims-mid
240284
#
241285
```
242286

243287
3. Access the Claims Web API application.
244288

245-
Retrieve the Public IP address of the Nginx ingress controller. See the command snippet below.
246-
247289
```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
249291
# The ALB Public IP address should be listed under column 'EXTERNAL-IP' in the command output.
250292
#
251-
$ kubectl get svc -n ingress-basic
293+
$ kubectl get svc -n dev-claims-mid
252294
#
253295
```
254296

255297
Access the Claims Web API service using a browser eg., http://[ALB Public IP]/api/v1/claims.
256298

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

Comments
 (0)