Last active
January 14, 2025 08:21
-
-
Save Debjyoti30/ff3bec45dbe2935cfd3d0af7e4bcce1e to your computer and use it in GitHub Desktop.
Azure container registry & Azure Container app Managed environment Bicep Module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Author: Debjyoti Ganguly | |
| Date: 14th Jan 2025 | |
| */ | |
| @description('The name of the Azure Container Registry') | |
| param registryName string | |
| @description('The location of the Azure Container Registry') | |
| param location string | |
| @description('The SKU of the Azure Container Registry') | |
| param sku string = 'Premium' | |
| resource acr 'Microsoft.ContainerRegistry/registries@2022-02-01-preview' = { | |
| name: registryName | |
| location: location | |
| sku: { | |
| name: sku | |
| } | |
| properties: { | |
| adminUserEnabled: false | |
| networkRuleSet: { | |
| defaultAction: 'Deny' | |
| virtualNetworkRules: [] | |
| ipRules: [] | |
| } | |
| encryption: { | |
| status: 'enabled' | |
| keyVaultProperties: {} | |
| } | |
| } | |
| identity: { | |
| type: 'SystemAssigned' | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Author: Debjyoti Ganguly | |
| Date: 14th Jan 2025 | |
| */ | |
| @description('The name of the Azure Container App Managed Environment') | |
| param environmentName string | |
| @description('The location of the Azure Container App Managed Environment') | |
| param location string | |
| @description('The name of the virtual network to associate with the environment') | |
| param virtualNetworkName string | |
| @description('The name of the subnet within the virtual network') | |
| param subnetName string | |
| @description('The resource group of the virtual network') | |
| param virtualNetworkResourceGroup string | |
| resource containerAppEnv 'Microsoft.App/managedEnvironments@2022-03-01' = { | |
| name: environmentName | |
| location: location | |
| properties: { | |
| virtualNetworkConfiguration: { | |
| infrastructureSubnetId: resourceId(virtualNetworkResourceGroup, 'Microsoft.Network/virtualNetworks/subnets', virtualNetworkName, subnetName) | |
| } | |
| zoneRedundant: true | |
| appLogsConfiguration: { | |
| destination: 'log-analytics' | |
| logAnalyticsConfiguration: { | |
| customerId: reference(logAnalyticsWorkspaceId, '2020-08-01').customerId | |
| sharedKey: listKeys(logAnalyticsWorkspaceId, '2020-08-01').primarySharedKey | |
| } | |
| } | |
| } | |
| identity: { | |
| type: 'SystemAssigned' | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @description('The name of the Azure Container Registry') | |
| param registryName string | |
| @description('The location for all resources') | |
| param location string | |
| @description('The name of the Azure Container App Managed Environment') | |
| param environmentName string | |
| @description('The name of the virtual network') | |
| param virtualNetworkName string | |
| @description('The name of the subnet within the virtual network') | |
| param subnetName string | |
| @description('The resource group of the virtual network') | |
| param virtualNetworkResourceGroup string | |
| module acrModule './acr.bicep' = { | |
| name: 'deployAcr' | |
| params: { | |
| registryName: registryName | |
| location: location | |
| } | |
| } | |
| module containerAppEnvModule './containerAppEnv.bicep' = { | |
| name: 'deployContainerAppEnv' | |
| params: { | |
| environmentName: environmentName | |
| location: location | |
| virtualNetworkName: virtualNetworkName | |
| subnetName: subnetName | |
| virtualNetworkResourceGroup: virtualNetworkResourceGroup | |
| } | |
| } | |
| resource roleAssignment 'Microsoft.Authorization/roleAssignments@2020-10-01-preview' = { | |
| name: guid(containerAppEnvironment.id, 'AcrPullRoleAssignment') | |
| properties: { | |
| principalId: containerAppEnvironment.identity.principalId | |
| roleDefinitionId: '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/{acrPullRoleDefinitionId}' | |
| scope: acr.id | |
| } | |
| } | |
| output containerAppEnvironmentId string = containerAppEnvironment.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment