Skip to content

Commit ea44adc

Browse files
authored
Merge pull request #273036 from ChenTanyi/main
add service connector with app configuration in IaC docs
2 parents 6700a67 + c5a3feb commit ea44adc

File tree

1 file changed

+62
-19
lines changed

1 file changed

+62
-19
lines changed

articles/service-connector/how-to-build-connections-with-iac-tools.md

Lines changed: 62 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,35 @@ Service Connector helps users connect their compute services to target backing s
1717

1818
## Solution overview
1919

20-
Translating the infrastructure to IaC templates usually involves two major parts: the logics to provision source and target services, and the logics to build connections. To implement the logics to provision source and target services, there are two options:
20+
Translating the infrastructure to IaC templates usually involves two major parts: the logic to provision source and target services, and the logic to build connections. To implement the logic to provision source and target services, there are two options:
2121

22-
* Authoring the template from scratch.
23-
* Exporting the template from Azure and polish it.
22+
* Authoring the template from scratch
23+
* Exporting the template from Azure and polish it
2424

25-
To implement the logics to build connections, there are also two options:
25+
To implement the logic to build connections, there are three options:
2626

27-
* Using Service Connector in the template.
28-
* Using template logics to configure source and target services directly.
27+
* Using Service Connector and store configuration in App Configuration
28+
* Using Service Connector in the template
29+
* Using template logic to configure source and target services directly
2930

3031
Combinations of these different options can produce different solutions. Due to [IaC limitations](./known-limitations.md) in Service Connector, we recommend that you implement the following solutions in the order presented below. To apply these solutions, you must understand the IaC tools and the template authoring grammar.
3132

3233
| Solution | Provision source and target | Build connection | Applicable scenario | Pros | Cons |
3334
| :------: | :-------------------------: | :-------------------------------------------------------: | :----------------------------------------------------------------------: | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
34-
| 1 | Authoring from scratch | Use Service Connector | Has liveness check on the cloud resources before allowing live traffics | - Template is simple and readable<br />- Service Connector brings extra values | - Cost to check cloud resources liveness |
35-
| 2 | Authoring from scratch | Configure source and target services directly in template | No liveness check on the cloud resources | - Template is simple and readable | - Service Connector features aren't available |
36-
| 3 | Export and polish | Use Service Connector | Has liveness check on the cloud resources before allowing live traffics | - Resources are exactly the same as in the cloud<br />- Service Connector brings extra values | - Cost to check cloud resources liveness<br />- Supports only ARM templates<br />- Efforts required to understand and polish the template |
37-
| 4 | Export and polish | Configure source and target services directly in template | No liveness check on the cloud resources | - Resources are exactly same as on the cloud | - Support only ARM template<br />- Efforts to understand and polish the template<br />- Service Connector features aren't available |
35+
| 1 | Authoring from scratch | Use Service Connector and store configuration in App Configuration | Has liveness check on the cloud resources before allowing live traffic | - Template is simple and readable<br />- Service Connector brings additional value<br />- No IaC problem is introduced by Service Connector | - Need extra dependency to read configuration from App Configuration<br />- Cost to check cloud resources liveness |
36+
| 2 | Authoring from scratch | Use Service Connector | Has liveness check on the cloud resources before allowing live traffic | - Template is simple and readable<br />- Service Connector brings additional value | - Cost to check cloud resources liveness |
37+
| 3 | Authoring from scratch | Configure source and target services directly in template | No liveness check on the cloud resources | - Template is simple and readable | - Service Connector features aren't available |
38+
| 4 | Export and polish | Use Service Connector and store configuration in App Configuration | Has liveness check on the cloud resources before allowing live traffic | - Resources are exactly the same as in the cloud<br />- Service Connector brings additional value<br />- No IaC problem is introduced by Service Connector | - Need extra dependency to read configuration from App Configuration<br />- Cost to check cloud resources liveness<br />- Supports only ARM templates<br />- Efforts required to understand and polish the template |
39+
| 5 | Export and polish | Use Service Connector | Has liveness check on the cloud resources before allowing live traffic | - Resources are exactly the same as in the cloud<br />- Service Connector brings additional value | - Cost to check cloud resources liveness<br />- Supports only ARM templates<br />- Efforts required to understand and polish the template |
40+
| 6 | Export and polish | Configure source and target services directly in template | No liveness check on the cloud resources | - Resources are exactly same as on the cloud | - Support only ARM template<br />- Efforts to understand and polish the template<br />- Service Connector features aren't available |
3841

3942
## Authoring templates
4043

41-
The following sections show how to create a web app and a storage account and connect them with a system-assigned identity using Bicep. It shows how to do this both using Service Connector and using template logics.
44+
The following sections show how to create a web app and a storage account and connect them with a system-assigned identity using Bicep. It shows how to do this both using Service Connector and using template logic.
4245

4346
### Provision source and target services
4447

45-
**Authoring from scratch**
48+
#### Authoring from scratch
4649

4750
Authoring the template from scratch is the preferred and recommended way to provision source and target services, as it's easy to get started and makes the template simple and readable. Following is an example, using a minimal set of parameters to create a webapp and a storage account.
4851

@@ -107,17 +110,57 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' = {
107110
}
108111
```
109112

110-
**Export and polish**
113+
#### Export and polish
111114

112115
If the resources you're provisioning are exactly the same ones as the ones you have in the cloud, exporting the template from Azure might be another option. The two premises of this approach are: the resources exist in Azure and you're using ARM templates for your IaC. The `Export template` button is usually at the bottom of the sidebar on Azure portal. The exported ARM template reflects the resource's current states, including the settings configured by Service Connector. You usually need to know about the resource properties to polish the exported template.
113116

114117
:::image type="content" source="./media/how-to/export-webapp-template.png" alt-text="Screenshot of the Azure portal, exporting arm template of a web app.":::
115118

116-
### Build connection logics
119+
### Build connection logic
117120

118-
**Using Service Connector**
121+
#### Using Service Connector and storing configuration in App Configuration
119122

120-
Creating connections between the source and target service using Service Connector is the preferred and recommended way if the [Service Connector ](./known-limitations.md)[IaC limitation](./known-limitations.md) doesn't matter for your scenario. Service Connector makes the template simpler and also provides additional elements, such as the connection health validation, which you won't have if you're building connections through template logics directly.
123+
Using the App Configuration to store configuration naturally supports IaC scenarios. We therefore recommend you use this method to build your IaC template if possible.
124+
125+
For simple portal instructions, you can refer to [this App Configuration tutorial](./tutorial-portal-app-configuration-store.md). To add this feature into a bicep file, add the App Configuration ID in the Service Connector payload.
126+
127+
```bicep
128+
resource webApp 'Microsoft.Web/sites@2022-09-01' existing = {
129+
name: webAppName
130+
}
131+
132+
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' existing = {
133+
name: storageAccountName
134+
}
135+
136+
resource appConfiguration 'Microsoft.AppConfiguration/configurationStores@2023-03-01' existing = {
137+
name: appConfigurationName
138+
}
139+
140+
resource serviceConnector 'Microsoft.ServiceLinker/linkers@2022-05-01' = {
141+
name: connectorName
142+
scope: webApp
143+
properties: {
144+
clientType: 'python'
145+
targetService: {
146+
type: 'AzureResource'
147+
id: storageAccount.id
148+
}
149+
authInfo: {
150+
authType: 'systemAssignedIdentity'
151+
}
152+
configurationInfo: {
153+
configurationStore: {
154+
appConfigurationId: appConfiguration.id
155+
}
156+
}
157+
}
158+
}
159+
```
160+
161+
#### Using Service Connector
162+
163+
Creating connections between the source and target service using Service Connector is the preferred and recommended way if the [Service Connector ](./known-limitations.md)[IaC limitation](./known-limitations.md) doesn't matter for your scenario. Service Connector makes the template simpler and also provides additional elements, such as the connection health validation, which you won't have if you're building connections through template logic directly.
121164

122165
```bicep
123166
// The template builds a connection between a webapp and a storage account
@@ -159,9 +202,9 @@ For the formats of properties and values needed when creating a Service Connecto
159202

160203
:::image type="content" source="./media/how-to/export-sc-template.png" alt-text="Screenshot of the Azure portal, exporting arm template of a service connector resource.":::
161204

162-
**Using template logics**
205+
#### Using template logic
163206

164-
For the scenarios where the Service Connector [IaC limitation](./known-limitations.md) matters, consider building connections using the template logics directly. The following template is an example showing how to connect a storage account to a web app using a system-assigned identity.
207+
For the scenarios where the Service Connector [IaC limitation](./known-limitations.md) matters, consider building connections using the template logic directly. The following template is an example showing how to connect a storage account to a web app using a system-assigned identity.
165208

166209
```bicep
167210
// The template builds a connection between a webapp and a storage account
@@ -207,7 +250,7 @@ resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
207250
}
208251
```
209252

210-
When building connections using template logics directly, it's crucial to understand what Service Connector does for each kind of authentication type, as the template logics are equivalent to the Service Connector backend operations. The following table shows the operation details that you need translate to template logics for each kind of authentication type.
253+
When building connections using template logic directly, it's crucial to understand what Service Connector does for each kind of authentication type, as the template logic is equivalent to the Service Connector backend operations. The following table shows the operation details that you need to translate to template logic for each kind of authentication type.
211254

212255
| Auth type | Service Connector operations |
213256
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

0 commit comments

Comments
 (0)