I have an app that has a bicep file (to deploy azure app service) which calls a template module(app service template) in another repository. The template module refer multiple modules in same repository. It calls one module for app service plan, one for app insight, one for app service.
Now I would like to have the app service have a connection string setting to be added which I think can be achieved with resource symbolicname ‘Microsoft.Web/sites/config@2022-03-01’ but it needs a parent parameter which is resource name. I am struggling to figure out a way to achieve this.
//main bicep of repository 1
module appServiceTemplateModule '../appservicetemplate.bicep' = {
name: ''
params: {
aspName: 'aspName'
aiName: 'aiName'
asName: 'asName'
appSettings: [
{
name: ''
value:
}
{
name: ''
value:
}
{
name: 'ApplicationInsightsAgent_EXTENSION_VERSION'
value: '~2'
}
]
}
}
//Template Repo
//paramaters
//variables
module appserviceplanModule 'appserviceplan.bicep' = {
name: hostingModule
params: {
}
}
module appInsightModule 'appinsights.bicep' = {
name: aiModule
params: {
}
}
module appServiceModule 'appservices.bicep' = {
name: asModule
params: {
}
dependsOn: [ appserviceplanModule, appInsightModule ]
}
Template repo has individual biceps being called.
I want the bicep files to remain generic so I do not want the appservices.bicep file to have Microsoft.Web/sites/config@2022-03-01 as a resource which can select the app service resource as parent. Stuck with how to achieve this.
Please let me know if any additional details are required.
2
Answers
Another way to get this done which I tried as well You can create this object from your calling main bicep that calls template module
Main bicep that calls can have it declared like this
Use a condition to determine whether or not to create it…
if(!empty(connectionstrings))
I’d probably put all the logic in your appservicetemplate.bicep file and add a new
connectionstrings
parameter.