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
@@ -31,51 +31,35 @@ In this quickstart, you will incorporate Azure App Configuration Kubernetes Prov
31
31
> The Azure Cloud Shell is a free, interactive shell that you can use to run the command line instructions in this article. It has common Azure tools preinstalled, including the .NET Core SDK. If you're logged in to your Azure subscription, launch your [Azure Cloud Shell](https://shell.azure.com) from shell.azure.com. You can learn more about Azure Cloud Shell by [reading our documentation](../cloud-shell/overview.md)
32
32
>
33
33
34
-
## Create an application consumes environment variables
35
-
If you already have an application that is consuming environment variables as configuration, you can just skip this step. We just create an ASP.NET Core Web App `MyWebApp` as an example.
36
-
34
+
## Create an application running in AKS
35
+
In this section, we present how to create an ASP.NET Core web application that consumes environment variables as configuration and run it in Azure Kubernetes Service. This part has nothing to do with Azure App Configuration or Azure App Configuration Kubernetes Provider, it just for demonstrating the end-to-end usage scenario of Azure App Configuration Kubernetes Provider later. If you already have an application that is consuming environment variables as configuration in Kubernetes, you can just skip this and go to [Use App Configuration Kubernetes Provider](#use-app-configuration-kubernetes-provider).
36
+
### Create an application
37
37
1. Use the .NET Core command-line interface (CLI) to create a new ASP.NET Core web app project. Run the following command to create an ASP.NET Core web app in a new TestAppConfig folder:
38
38
```dotnetcli
39
39
dotnet new webapp --output MyWebApp --framework net6.0
40
40
```
41
41
42
-
1. Open *Index.cshtml.cs* in the Pages directory, and update the `IndexModel` class with the following code.
If you already have an application, you can containerize it in a way that depends on your application. We just show you how to build the `MyWebApp` project to an image.
62
+
### Containerize the application
79
63
1. Run the [dotnet publish](/dotnet/core/tools/dotnet-publish) command to build the app in release mode and create the assets in the published folder.
80
64
``` dotnetcli
81
65
dotnet publish -c Release -o published
@@ -92,7 +76,7 @@ If you already have an application, you can containerize it in a way that depend
92
76
docker build --tag aspnetapp .
93
77
```
94
78
95
-
## Push the image to Azure Container Registry
79
+
###Push the image to the registry
96
80
1. Run the [az acr login](/cli/azure/acr#az-acr-login) command to log in to the registry.
97
81
98
82
```azurecli
@@ -124,47 +108,9 @@ If you already have an application, you can containerize it in a way that depend
124
108
docker push myregistry.azurecr.io/aspnetapp:v1
125
109
```
126
110
127
-
## Configure the Azure App Configuration store
128
-
1. Add the key-values to your Azure App Configuration that should be consumed as environment variables by your application. We're just using key-values that be consumed by `MyWebApp` as an example, add following key-values to the App Configuration store and leave **Label** and **Content Type** with their default values. For more information about how to add key-values to a store using the Azure portal or the CLI, go to [Create a key-value](./quickstart-azure-app-configuration-create.md#create-a-key-value).
129
-
130
-
|**Key**|**Value**|
131
-
|---|---|
132
-
|Settings__FontColor|*Red*|
133
-
|Settings__Message|*Hello from Azure App Configuration*|
134
-
135
-
1. Enable System Assigned Managed Identity of AKS NodePool
136
-
137
-
Go to the corresponding Virtual Machine Scale Sets resource of AKS, and enable system-assigned managed identity on the Virtual Machine Scale Sets by following this [doc](/azure/active-directory/managed-identities-azure-resources/qs-configure-portal-windows-vmss#enable-system-assigned-managed-identity-on-an-existing-virtual-machine-scale-set).
138
-
139
-
1. Assign Data Reader role to the System Assigned Managed Identity
140
-
141
-
Once the system-assigned managed identity has been enabled, you need to grant it read access to Azure AppConfiguration. You can do it by following the instructions in this [doc](/azure/azure-app-configuration/howto-integrate-azure-managed-service-identity?tabs=core5x&pivots=framework-dotnet#grant-access-to-app-configuration).
142
-
143
-
## Install App Configuration Kubernetes Provider to your AKS cluster
144
-
145
-
1. Get the credential to manage your AKS cluster, replace the `name` and `resource-group` parameters with yours:
146
-
```bash
147
-
az aks get-credentials --name my_aks --resource-group my_aks_resource_group
148
-
```
149
-
1. Install Azure App Configuration Kubernetes Provider to your AKS cluster using `helm`:
1. Create an *AKS-AppConfiguration-Demo* directory in the root directory of your project.
155
113
156
-
1. Create a *AKS-AppConfiguration-Demo* directory in the root directory of your project.
157
-
1. Create *appConfigurationProvider.yaml* in the *AKS-AppConfiguration-Demo* directory with the following YAML content. Replace the value of the `endpoint` field with the endpoint of your Azure AppConfiguration store.
158
-
``` yaml
159
-
apiVersion: azconfig.io/v1beta1
160
-
kind: AzureAppConfigurationProvider
161
-
metadata:
162
-
name: appconfigurationprovider-sample
163
-
spec:
164
-
endpoint: https://myappconfig.azconfig.io
165
-
target:
166
-
configMapName: demo-configmap
167
-
```
168
114
1. Create *deployment.yaml* in the *AKS-AppConfiguration-Demo* directory with the following YAML content. Replace the value of `template.spec.containers.image` with the image you created in the previous step.
169
115
``` yaml
170
116
apiVersion: apps/v1
@@ -188,9 +134,11 @@ If you already have an application, you can containerize it in a way that depend
188
134
image: myregistry.azurecr.io/aspnetapp:v1
189
135
ports:
190
136
- containerPort: 80
191
-
envFrom:
192
-
- configMapRef:
193
-
name: demo-configmap
137
+
env:
138
+
- name: Settings__Message
139
+
value: "Hello from the environment variable"
140
+
- name: Settings__FontColor
141
+
value: "Orange"
194
142
```
195
143
1. Create *service.yaml* in the *AKS-AppConfiguration-Demo* with the following YAML content.
196
144
``` yaml
@@ -205,15 +153,108 @@ If you already have an application, you can containerize it in a way that depend
1. Run the following command and get the External IP that exposed by the LoadBalancer service.
164
+
``` bash
165
+
kubectl get service configmap-demo-service -n quickstart-appconfig
166
+
```
167
+
168
+
1. Open a browser window, use the External IP of the service you get in previous step to visit the app. Your browser should display a page similar to the image below.
169
+
170
+

171
+
172
+
## Use App Configuration Kubernetes Provider
173
+
### Configure the Azure App Configuration store
174
+
1. Add the key-values to your Azure App Configuration that should be consumed as environment variables by your application. We're just using key-values that be consumed by `MyWebApp` as an example, add following key-values to the App Configuration store and leave **Label** and **Content Type** with their default values. For more information about how to add key-values to a store using the Azure portal or the CLI, go to [Create a key-value](./quickstart-azure-app-configuration-create.md#create-a-key-value).
175
+
176
+
|**Key**|**Value**|
177
+
|---|---|
178
+
|Settings__FontColor|*Green*|
179
+
|Settings__Message|*Hello from Azure App Configuration*|
180
+
181
+
1. Enable System Assigned Managed Identity of AKS NodePool
182
+
183
+
Go to the corresponding Virtual Machine Scale Sets resource of AKS, and enable system-assigned managed identity on the Virtual Machine Scale Sets by following this [doc](/azure/active-directory/managed-identities-azure-resources/qs-configure-portal-windows-vmss#enable-system-assigned-managed-identity-on-an-existing-virtual-machine-scale-set).
184
+
185
+
1. Assign Data Reader role to the System Assigned Managed Identity
186
+
187
+
Once the system-assigned managed identity has been enabled, you need to grant it read access to Azure AppConfiguration. You can do it by following the instructions in this [doc](/azure/azure-app-configuration/howto-integrate-azure-managed-service-identity?tabs=core5x&pivots=framework-dotnet#grant-access-to-app-configuration).
188
+
189
+
### Install App Configuration Kubernetes Provider to AKS cluster
190
+
1. Get the credential to manage your AKS cluster, replace the `name` and `resource-group` parameters with yours:
191
+
```bash
192
+
az aks get-credentials --name my_aks --resource-group my_aks_resource_group
193
+
```
194
+
195
+
1. Install Azure App Configuration Kubernetes Provider to your AKS cluster using `helm`:
1. Create *appConfigurationProvider.yaml* with the following YAML content. Replace the value of the `endpoint` field with the endpoint of your Azure AppConfiguration store.
203
+
``` yaml
204
+
apiVersion: azconfig.io/v1beta1
205
+
kind: AzureAppConfigurationProvider
206
+
metadata:
207
+
name: appconfigurationprovider-sample
208
+
spec:
209
+
endpoint: https://myappconfig.azconfig.io
210
+
target:
211
+
configMapName: demo-configmap
212
+
```
213
+
214
+
1. Apply *appConfigurationProvider.yaml* to the AKS cluster.
If namespace does not exists, run the following command to create it first.
219
+
``` bash
220
+
kubectl create namespace quickstart-appconfig
221
+
```
222
+
223
+
### Update application deployment
224
+
1. Update the *deployment.yaml* to use the configMap `demo-configmap` as environment variable.
225
+
226
+
Replace the whole `env` section
227
+
``` yaml
228
+
env:
229
+
- name: Settings__Message
230
+
value: "Hello from the environment variable"
231
+
- name: Settings__FontColor
232
+
value: "Orange"
233
+
```
234
+
with:
235
+
``` yaml
236
+
envFrom:
237
+
- configMapRef:
238
+
name: demo-configmap
239
+
```
215
240
216
-
To check the synchronization status of AppConfigurationProvider, run the following command in your terminal. If the `phase` property in the `status` section of the output is `COMPLETE` , it means that the key-values have been successfully synced from Azure App Configuration.
241
+
1. Apply the updated *deployment.yaml* to the AKS cluster
Refresh the browser, the page shows with updated content.
248
+
249
+

250
+
251
+
### Validation and troubleshooting
252
+
A configMap *demo-configmap* is supposed to be created in the *quickstart-appconfig* namespace by the Azure App Configuration Kubernetes Provider.
253
+
``` bash
254
+
kubectl get configmap demo-configmap -n quickstart-appconfig
255
+
```
256
+
257
+
In addition to check the existence of target configMap, you can also check the synchronization status of AppConfigurationProvider, run the following command in your terminal. If the `phase` property in the `status` section of the output is `COMPLETE` , it means that the key-values have been successfully synced from Azure App Configuration.
217
258
```bash
218
259
kubectl get AppConfigurationProvider appconfigurationprovider-sample -n quickstart-appconfig -o yaml
219
260
```
@@ -223,17 +264,6 @@ kubectl get AppConfigurationProvider appconfigurationprovider-sample -n quicksta
A configMap *demo-configmap* is being created in the *quickstart-appconfig* namespace
228
-
``` bash
229
-
kubectl get configmap demo-configmap -n quickstart-appconfig
230
-
```
231
-
232
-
## Validate key-values from Azure App Configuration are affecting the app.
233
-
Run the following command and get the External IP that exposed by the LoadBalancer service. Use it to visit the web app, you'll see that the configuration settings from the Azure App Configuration store are affecting the page.
234
-
```bash
235
-
kubectl get service configmap-demo-service -n quickstart-appconfig
236
-
```
237
267
238
268
## Clean up resources
239
269
1. Remove the resources that have been deployed to AKS
0 commit comments