Skip to content

Commit fa66b4b

Browse files
chore: Module 10 ux consistency
1 parent 291e775 commit fa66b4b

1 file changed

Lines changed: 113 additions & 15 deletions

File tree

docs/aca/10-aca-iac-bicep/index.md

Lines changed: 113 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ To begin, we need to define the Bicep modules that will be required to generate
4040
To proceed, you must install an extension called [Bicep](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-bicep). This extension will simplify building Bicep files as it offers IntelliSense, Validation, listing all available resource types, etc..
4141

4242
#### 2. Define an Azure Container Apps Environment
43-
Add a new folder named `bicep` on the root project directory, then add another folder named `modules`. Add a new file named `container-apps-environment.bicep`. The content of the file can be found [at this location](https://github.com/Azure/aca-dotnet-workshop/blob/main/bicep/modules/container-apps-environment.bicep).
43+
Add a new folder named `bicep` on the root project directory, then add another folder named `modules`. Add file as shown below:
44+
45+
=== "container-apps-environment.bicep"
46+
47+
```bicep
48+
--8<-- "https://raw.githubusercontent.com/Azure/aca-dotnet-workshop/main/bicep/modules/container-apps-environment.bicep"
49+
```
4450

4551
??? tip "What we've added in the Bicep file above"
4652
- The module takes multiple parameters, all of which are set to default values. This indicates that if no value is specified, the default value will be utilized.
@@ -53,44 +59,76 @@ Add a new folder named `bicep` on the root project directory, then add another f
5359
- The output of this module are a is parameter named `applicationInsightsName`. This output is needed as an input for a subsequent module.
5460

5561
#### 3. Define an Azure Key Vault Resource
56-
Add a new file named `key-vault.bicep` under the folder `bicep\modules`. The content of the file can be found [at this location](https://github.com/Azure/aca-dotnet-workshop/blob/main/bicep/modules/key-vault.bicep).
62+
63+
Add file as shown below under the folder `bicep\modules`:
64+
65+
=== "key-vault.bicep"
66+
67+
```bicep
68+
--8<-- "https://raw.githubusercontent.com/Azure/aca-dotnet-workshop/main/bicep/modules/key-vault.bicep"
69+
```
5770

5871
??? tip "What we've added in the Bicep file above"
5972
- This module will create the Azure Key Vault resource which will be used to store secrets.
6073
- The output of this module is a single parameter named `keyVaultId`. This output is needed as an input for a subsequent module.
6174

6275
#### 4. Define a Azure Service Bus Resource
63-
Add a new file named `service-bus.bicep` under the folder `bicep\modules`. The content of the file can be found [at this location](https://github.com/Azure/aca-dotnet-workshop/blob/main/bicep/modules/service-bus.bicep).
76+
77+
Add file as shown below under the folder `bicep\modules`:
78+
79+
=== "service-bus.bicep"
80+
81+
```bicep
82+
--8<-- "https://raw.githubusercontent.com/Azure/aca-dotnet-workshop/main/bicep/modules/service-bus.bicep"
83+
```
6484

6585
??? tip "What we've added in the Bicep file above"
6686
- This module will create the Azure Service resource, a topic, a subscription for the consumer, and an authorization rule with `Manage` permissions.
6787
- The output of this module will return three output parameters which will be used as an input for a subsequent module.
6888

6989
#### 5. Define an Azure CosmosDb Resource
7090

71-
Add a new file named `cosmos-db.bicep` under the folder `bicep\modules`. The content of the file can be found [at this location](https://github.com/Azure/aca-dotnet-workshop/blob/main/bicep/modules/cosmos-db.bicep)
91+
Add file as shown below under the folder `bicep\modules`:
92+
93+
=== "cosmos-db.bicep"
94+
95+
```bicep
96+
--8<-- "https://raw.githubusercontent.com/Azure/aca-dotnet-workshop/main/bicep/modules/cosmos-db.bicep"
97+
```
7298

7399
??? tip "What we've added in the Bicep file above"
74100
- This module will create the Azure CosmosDB account, a CosmosDB database, and a CosmosDB collection.
75101
- The output of this module will return three output parameters which will be used as an input for a subsequent module.
76102

77103
#### 6. Define an Azure Storage Resource
78104

79-
Add a new file named `storage-account.bicep` under the folder `bicep\modules`. The content of the file can be found [at this location](https://github.com/Azure/aca-dotnet-workshop/blob/main/bicep/modules/storage-account.bicep)
105+
Add file as shown below under the folder `bicep\modules`:
106+
107+
=== "storage-account.bicep"
108+
109+
```bicep
110+
--8<-- "https://raw.githubusercontent.com/Azure/aca-dotnet-workshop/main/bicep/modules/storage-account.bicep"
111+
```
80112

81113
??? tip "What we've added in the Bicep file above"
82114
- This module will create the Azure Storage account, a storage queue service, and a queue.
83115
- The output of this module will be a single output parameter which will be used as an input for a subsequent module.
84116

85117
#### 7. Define Dapr Components
86118

87-
Next we will define all dapr components used in the solution in a single bicep module. To accomplish this, add a new file called `dapr-components.bicep` under the folder `bicep\modules`. The content of the file can be found [at this location](https://github.com/Azure/aca-dotnet-workshop/blob/main/bicep/modules/dapr-components.bicep)
119+
Next we will define all dapr components used in the solution in a single bicep module. To accomplish this, add a new file under the folder `bicep\modules` as shown below:
120+
121+
=== "dapr-components.bicep"
122+
123+
```bicep
124+
--8<-- "https://raw.githubusercontent.com/Azure/aca-dotnet-workshop/main/bicep/modules/dapr-components.bicep"
125+
```
88126

89127
??? tip "What we've added in the Bicep file above"
90128
- This module will be responsible for creating all dapr components used in the solution. It accepts various input parameters needed by the dapr components.
91129
- Notice how we are using the keyword `existing` to obtain a strongly typed reference to the pre-created resource
92130

93-
```shell
131+
```shell hl_lines="1 5"
94132
resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2022-03-01' existing = {
95133
name: containerAppsEnvironmentName
96134
}
@@ -101,21 +139,41 @@ Next we will define all dapr components used in the solution in a single bicep m
101139
```
102140

103141
#### 8. Create Secrets Into Azure Key Vault
142+
104143
This module will have the responsibility of generating the secrets and saving them in Azure Key Vault. Additionally, it will establish a role assignment for the backend processor service, specifically of type `Azure Role Key Vault Secrets User`, which will allow the service to access the Key Vault and retrieve the secrets.
105144

106-
To achieve this, create a new directory called `container-apps\secrets` within the `modules` folder, and subsequently, introduce a new file named `processor-backend-service-secrets.bicep` within the `container-apps\secrets` folder. The content of the file can be found [at this location](https://github.com/Azure/aca-dotnet-workshop/blob/main/bicep/modules/container-apps/secrets/processor-backend-service-secrets.bicep).
145+
To achieve this, create a new directory called `container-apps\secrets` within the `modules` folder. Add new file as shown below under the folder `bicep\modules\container-apps\secrets`:
146+
147+
=== "processor-backend-service-secrets.bicep"
148+
149+
```bicep
150+
--8<-- "https://raw.githubusercontent.com/Azure/aca-dotnet-workshop/main/bicep/modules/container-apps/secrets/processor-backend-service-secrets.bicep"
151+
```
107152

108153
#### 9. Define the Frontend Service Azure Container App
109-
We will now begin defining the modules that are necessary for producing the container apps, starting with the Frontend App. To initiate this process, create a new file named `webapp-frontend-service.bicep` within the `modules\container-apps` directory. The content of the file can be found [at this location](https://github.com/Azure/aca-dotnet-workshop/blob/main/bicep/modules/container-apps/webapp-frontend-service.bicep).
154+
We will now begin defining the modules that are necessary for producing the container apps, starting with the Frontend App. To initiate this process, add a new file under the folder `bicep\modules\container-apps` as shown below:
155+
156+
=== "webapp-frontend-service.bicep"
157+
158+
```bicep
159+
--8<-- "https://raw.githubusercontent.com/Azure/aca-dotnet-workshop/main/bicep/modules/container-apps/webapp-frontend-service.bicep"
160+
```
110161

111162
??? tip "What we've added in the Bicep file above"
112163
- Observe the usage of the `@secure` attribute on input parameters that contain confidential information or keys. This attribute may be applied to both string and object parameters that encompass secretive values. By implementing this attribute, Azure will abstain from presenting the parameter values within the deployment logs or on the terminal if you happen to be utilizing Azure CLI.
113164
- The output parameters of this module will provide the fully qualified domain name (FQDN) for the frontend container application.
114165

115166
#### 10. Define the Backend Api Service Azure Container App
116-
Add a new file named `webapi-backend-service.bicep` under the folder `modules\container-apps`. The content of the file can be found [at this location](https://github.com/Azure/aca-dotnet-workshop/blob/main/bicep/modules/container-apps/webapi-backend-service.bicep).
167+
Add a new file under the folder `bicep\modules\container-apps` as shown below:
168+
169+
=== "webapi-backend-service.bicep"
170+
171+
```bicep
172+
--8<-- "https://raw.githubusercontent.com/Azure/aca-dotnet-workshop/main/bicep/modules/container-apps/webapi-backend-service.bicep"
173+
```
117174

118175
??? tip "What we've added in the Bicep file above"
176+
119177
- Notice how we are assigning the Cosmosdb account a read/write access using the `Cosmos DB Built-in Data Contributor` role to the Backend API system assigned identity, by using the code below:
120178

121179
```Shell
@@ -142,9 +200,17 @@ Add a new file named `webapi-backend-service.bicep` under the folder `modules\co
142200
```
143201

144202
#### 11. Define the Backend Processor Service Azure Container App
145-
Add a new file named `processor-backend-service.bicep` under the folder `modules\container-apps`. The content of the file can be found [at this location](https://github.com/Azure/aca-dotnet-workshop/blob/main/bicep/modules/container-apps/processor-backend-service.bicep).
203+
204+
Add a new file under the folder `bicep\modules\container-apps` as shown below:
205+
206+
=== "processor-backend-service.bicep"
207+
208+
```bicep
209+
--8<-- "https://raw.githubusercontent.com/Azure/aca-dotnet-workshop/main/bicep/modules/container-apps/processor-backend-service.bicep"
210+
```
146211

147212
??? tip "What we've added in the Bicep file above"
213+
148214
- Notice how we are assigning the role `Azure Service Bus Data Receiver` to the Backend Processor to be able to consume/read messages from Azure Service Bus Topic using Backend Processor system assigned identity, by using the code below:
149215
```Shell
150216
resource backendProcessorService_sb_role_assignment 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
@@ -172,11 +238,29 @@ Add a new file named `processor-backend-service.bicep` under the folder `modules
172238
scope: resourceGroup(keyVaultSubscriptionId, keyVaultResourceGroupName)
173239
}
174240
```
241+
175242
#### 12. Define a Container Module For the Three Container Apps
176-
This module will act as a container for the three Container Apps modules defined in the previous three steps. It is optional to create it, but it makes it easier when we invoke all the created modules as you will see in the next step. To create this module add a new file named `container-apps.bicep` under the folder `modules`. The content of the file can be found [at this location](https://github.com/Azure/aca-dotnet-workshop/blob/main/bicep/modules/container-apps.bicep).
243+
This module will act as a container for the three Container Apps modules defined in the previous three steps. It is optional to create it, but it makes it easier when we invoke all the created modules as you
244+
will see in the next step.
245+
246+
Add a new file under the folder `bicep\modules` as shown below:
247+
248+
=== "container-apps.bicep"
249+
250+
```bicep
251+
--8<-- "https://raw.githubusercontent.com/Azure/aca-dotnet-workshop/main/bicep/modules/container-apps.bicep"
252+
```
177253

178254
#### 13. Define the Main Module For the Solution
179-
Finally, we must specify the Main Bicep module that will connect all other modules together. This file will be referenced by the AZ CLI command when producing all resources. To achieve this, add a new file named `main.bicep` under the `bicep` directory. The contents of the file can be found at this [location](https://github.com/Azure/aca-dotnet-workshop/blob/main/bicep/main.bicep).
255+
Finally, we must specify the Main Bicep module that will connect all other modules together. This file will be referenced by the AZ CLI command when producing all resources.
256+
257+
To achieve this, add a new file under the `bicep` directory as shown below:
258+
259+
=== "main.bicep"
260+
261+
```bicep
262+
--8<-- "https://raw.githubusercontent.com/Azure/aca-dotnet-workshop/main/bicep/main.bicep"
263+
```
180264

181265
??? tip "What we've added in the Bicep file above"
182266

@@ -185,9 +269,23 @@ Finally, we must specify the Main Bicep module that will connect all other modul
185269
- When calling the module `container-apps.bicep`, some of the input params are expecting are referencing another resource, for example consider the input param named `cosmosDbName` and the value used is `cosmosDb.outputs.cosmosDbName`. This means that the module `cosmos-db.bicep` should be created successfully before creating the container apps module, this called Implicit dependency.
186270

187271
### Deploy the Infrastructure and Create the Components
188-
With the steps above completed we are ready to deploy all the different resources. We just need to create a parameters file which will simplify the invocation of the main bicep file. To achieve this, right click on file `main.bicep` and select `Generate Parameter File`. This will result in creating a file named `main.parameters.json` similar to the file found [here](https://github.com/Azure/aca-dotnet-workshop/blob/main/bicep/main.parameters.json).
189272

190-
To use this file, you need to edit this generated file and provide values for the parameters. You can use the same values provided on the github link. You only need to replace parameter values between the angle brackets `<>` with values related to your ACR resource and SendGrid.
273+
With the steps above completed we are ready to deploy all the different resources. We just need to create a parameters file which will simplify the invocation of the main bicep file.
274+
275+
To achieve this, right click on file `main.bicep` and select **Generate Parameter File**. This will result in creating a file named `main.parameters.json` similar to the file below:
276+
277+
???+ example
278+
=== "main.parameters.json"
279+
280+
```json
281+
--8<-- "https://raw.githubusercontent.com/Azure/aca-dotnet-workshop/main/bicep/main.parameters.json"
282+
```
283+
284+
!!! note
285+
286+
To use this file, you need to edit this generated file and provide values for the parameters. You can use the same values shown above in sample file.
287+
288+
You only need to replace parameter values between the angle brackets `<>` with values related to your ACR resource and SendGrid.
191289

192290
Start the deployment by calling `az deployment group create`. To accomplish this, open the PowerShell console and use the content below.
193291

0 commit comments

Comments
 (0)