Skip to content

Commit 9eaa609

Browse files
committed
Improve Azure resource naming for app service and function app
1 parent 56f4f84 commit 9eaa609

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

Labs/deploy/azuredeploy.bicep

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/* ***************************************************************
2+
Azure Cosmos DB + Azure OpenAI Python developer guide lab
3+
******************************************************************
4+
This Azure resource deployment template uses some of the following practices:
5+
- [Abbrevation examples for Azure resources](https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/resource-abbreviations)
6+
*/
7+
8+
19

210
/* *************************************************************** */
311
/* Parameters */
@@ -88,7 +96,7 @@ var mongovCoreSettings = {
8896

8997
var appServiceSettings = {
9098
plan: {
91-
name: '${name}-web-plan'
99+
name: '${name}-web'
92100
sku: appServiceSku
93101
}
94102
web: {
@@ -100,8 +108,8 @@ var appServiceSettings = {
100108
}
101109
*/
102110
}
103-
function: {
104-
name: '${name}-function'
111+
api: {
112+
name: '${name}-api'
105113
/*
106114
git: {
107115
repo: appGitRepository
@@ -213,7 +221,7 @@ resource openAiCompletionsModelDeployment 'Microsoft.CognitiveServices/accounts/
213221
/* *************************************************************** */
214222

215223
resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
216-
name: appServiceSettings.plan.name
224+
name: '${appServiceSettings.plan.name}-asp'
217225
location: location
218226
sku: {
219227
name: appServiceSettings.plan.sku
@@ -229,15 +237,6 @@ resource appServiceWeb 'Microsoft.Web/sites@2022-03-01' = {
229237
}
230238
}
231239

232-
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-09-01' = {
233-
name: '${replace(toLower(name), '-', '')}fnstorage'
234-
location: location
235-
kind: 'Storage'
236-
sku: {
237-
name: 'Standard_LRS'
238-
}
239-
}
240-
241240
resource appServiceWebSettings 'Microsoft.Web/sites/config@2022-03-01' = {
242241
parent: appServiceWeb
243242
name: 'appsettings'
@@ -258,7 +257,7 @@ resource appServiceWebSettings 'Microsoft.Web/sites/config@2022-03-01' = {
258257
}
259258

260259
resource appServiceWebInsights 'Microsoft.Insights/components@2020-02-02' = {
261-
name: appServiceWeb.name
260+
name: '${appServiceSettings.web.name}-appi'
262261
location: location
263262
kind: 'web'
264263
properties: {
@@ -285,8 +284,17 @@ resource appServiceWebDeployment 'Microsoft.Web/sites/sourcecontrols@2021-03-01'
285284
/* API Hosting - Azure Functions */
286285
/* *************************************************************** */
287286

287+
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-09-01' = {
288+
name: '${replace(toLower(appServiceSettings.api.name), '-', '')}funcst'
289+
location: location
290+
kind: 'Storage'
291+
sku: {
292+
name: 'Standard_LRS'
293+
}
294+
}
295+
288296
resource appServiceFunction 'Microsoft.Web/sites@2022-03-01' = {
289-
name: appServiceSettings.function.name
297+
name: '${appServiceSettings.api.name}-func'
290298
location: location
291299
kind: 'functionapp'
292300
properties: {
@@ -321,7 +329,7 @@ resource appServiceFunctionSettings 'Microsoft.Web/sites/config@2022-03-01' = {
321329
}
322330

323331
resource appServiceFunctionsInsights 'Microsoft.Insights/components@2020-02-02' = {
324-
name: appServiceFunction.name
332+
name: '${appServiceSettings.api.name}-appi'
325333
location: location
326334
kind: 'web'
327335
properties: {
@@ -351,4 +359,6 @@ resource appServiceFunctionsDeployment 'Microsoft.Web/sites/sourcecontrols@2021-
351359
/* Outputs */
352360
/* *************************************************************** */
353361

354-
output deployedUrl string = appServiceWeb.properties.defaultHostName
362+
output deployedWebUrl string = appServiceWeb.properties.defaultHostName
363+
364+
output deployedFunctionUrl string = appServiceFunction.properties.defaultHostName

0 commit comments

Comments
 (0)