Skip to content

Commit c04f6db

Browse files
committed
```text
refactor: Add User Assigned Managed Identity to web app deployment The code changes in the main.bicep and webapp.bicep files add support for User Assigned Managed Identity in the deployment of the web app. This allows the web app to access the SSL certificate stored in the KeyVault.
1 parent c27524e commit c04f6db

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

ocpp-server/infra/main.bicep

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ module webApp './modules/webapp.bicep' = {
8787
pubSubName: webPubSub.outputs.serviceName
8888
vnetName: virtualNetwork.outputs.vnetName
8989
subnetName: virtualNetwork.outputs.defaultSubnetName
90+
keyVaultIdentityName: keyVaultIdentityName
91+
keyVaultIdentityRG: keyVaultIdentityRG
9092
}
9193
}
9294

ocpp-server/infra/modules/webapp.bicep

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ param location string = resourceGroup().location // Location for all resources
55
param pubSubName string
66
param subnetName string
77
param vnetName string
8+
param keyVaultIdentityName string
9+
param keyVaultIdentityRG string
810

911
var appServicePlanName = toLower('AppServicePlan-${webAppName}')
1012
var webSiteName = toLower(webAppName)
@@ -24,6 +26,11 @@ resource subNet 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' existing
2426
parent: vNet
2527
}
2628

29+
resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = {
30+
name: keyVaultIdentityName
31+
scope: resourceGroup(keyVaultIdentityRG)
32+
}
33+
2734
// create an Application Insights resource
2835
resource appInsights 'Microsoft.Insights/components@2020-02-02-preview' = {
2936
name: appInsightsName
@@ -58,6 +65,12 @@ module storage 'storage.bicep' = {
5865
resource appService 'Microsoft.Web/sites@2020-06-01' = {
5966
name: webSiteName
6067
location: location
68+
identity: {
69+
type: 'UserAssigned'
70+
userAssignedIdentities: {
71+
'${identity.id}': {}
72+
}
73+
}
6174
properties: {
6275
serverFarmId: appServicePlan.id
6376
httpsOnly: true // Enable HTTPS only for improved security

0 commit comments

Comments
 (0)