|
| 1 | +metadata description = 'Creates an Azure Container Registry.' |
| 2 | +param name string |
| 3 | +param location string = resourceGroup().location |
| 4 | +param tags object = {} |
| 5 | + |
| 6 | +@description('Indicates whether admin user is enabled') |
| 7 | +param adminUserEnabled bool = false |
| 8 | + |
| 9 | +@description('Indicates whether anonymous pull is enabled') |
| 10 | +param anonymousPullEnabled bool = false |
| 11 | + |
| 12 | +@description('Azure ad authentication as arm policy settings') |
| 13 | +param azureADAuthenticationAsArmPolicy object = { |
| 14 | + status: 'enabled' |
| 15 | +} |
| 16 | + |
| 17 | +@description('Indicates whether data endpoint is enabled') |
| 18 | +param dataEndpointEnabled bool = false |
| 19 | + |
| 20 | +@description('Encryption settings') |
| 21 | +param encryption object = { |
| 22 | + status: 'disabled' |
| 23 | +} |
| 24 | + |
| 25 | +@description('Export policy settings') |
| 26 | +param exportPolicy object = { |
| 27 | + status: 'enabled' |
| 28 | +} |
| 29 | + |
| 30 | +@description('Metadata search settings') |
| 31 | +param metadataSearch string = 'Disabled' |
| 32 | + |
| 33 | +@description('Options for bypassing network rules') |
| 34 | +param networkRuleBypassOptions string = 'AzureServices' |
| 35 | + |
| 36 | +@description('Public network access setting') |
| 37 | +param publicNetworkAccess string = 'Enabled' |
| 38 | + |
| 39 | +@description('Quarantine policy settings') |
| 40 | +param quarantinePolicy object = { |
| 41 | + status: 'disabled' |
| 42 | +} |
| 43 | + |
| 44 | +@description('Retention policy settings') |
| 45 | +param retentionPolicy object = { |
| 46 | + days: 7 |
| 47 | + status: 'disabled' |
| 48 | +} |
| 49 | + |
| 50 | +@description('Scope maps setting') |
| 51 | +param scopeMaps array = [] |
| 52 | + |
| 53 | +@description('SKU settings') |
| 54 | +param sku object = { |
| 55 | + name: 'Basic' |
| 56 | +} |
| 57 | + |
| 58 | +@description('Soft delete policy settings') |
| 59 | +param softDeletePolicy object = { |
| 60 | + retentionDays: 7 |
| 61 | + status: 'disabled' |
| 62 | +} |
| 63 | + |
| 64 | +@description('Trust policy settings') |
| 65 | +param trustPolicy object = { |
| 66 | + type: 'Notary' |
| 67 | + status: 'disabled' |
| 68 | +} |
| 69 | + |
| 70 | +@description('Zone redundancy setting') |
| 71 | +param zoneRedundancy string = 'Disabled' |
| 72 | + |
| 73 | +@description('The log analytics workspace ID used for logging and monitoring') |
| 74 | +param workspaceId string = '' |
| 75 | + |
| 76 | +// 2023-11-01-preview needed for metadataSearch |
| 77 | +resource containerRegistry 'Microsoft.ContainerRegistry/registries@2023-11-01-preview' = { |
| 78 | + name: name |
| 79 | + location: location |
| 80 | + tags: tags |
| 81 | + sku: sku |
| 82 | + properties: { |
| 83 | + adminUserEnabled: adminUserEnabled |
| 84 | + anonymousPullEnabled: anonymousPullEnabled |
| 85 | + dataEndpointEnabled: dataEndpointEnabled |
| 86 | + encryption: encryption |
| 87 | + metadataSearch: metadataSearch |
| 88 | + networkRuleBypassOptions: networkRuleBypassOptions |
| 89 | + policies:{ |
| 90 | + quarantinePolicy: quarantinePolicy |
| 91 | + trustPolicy: trustPolicy |
| 92 | + retentionPolicy: retentionPolicy |
| 93 | + exportPolicy: exportPolicy |
| 94 | + azureADAuthenticationAsArmPolicy: azureADAuthenticationAsArmPolicy |
| 95 | + softDeletePolicy: softDeletePolicy |
| 96 | + } |
| 97 | + publicNetworkAccess: publicNetworkAccess |
| 98 | + zoneRedundancy: zoneRedundancy |
| 99 | + } |
| 100 | + |
| 101 | + resource scopeMap 'scopeMaps' = [for scopeMap in scopeMaps: { |
| 102 | + name: scopeMap.name |
| 103 | + properties: scopeMap.properties |
| 104 | + }] |
| 105 | +} |
| 106 | + |
| 107 | +// TODO: Update diagnostics to be its own module |
| 108 | +// Blocking issue: https://github.com/Azure/bicep/issues/622 |
| 109 | +// Unable to pass in a `resource` scope or unable to use string interpolation in resource types |
| 110 | +resource diagnostics 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = if (!empty(workspaceId)) { |
| 111 | + name: 'registry-diagnostics' |
| 112 | + scope: containerRegistry |
| 113 | + properties: { |
| 114 | + workspaceId: workspaceId |
| 115 | + logs: [ |
| 116 | + { |
| 117 | + category: 'ContainerRegistryRepositoryEvents' |
| 118 | + enabled: true |
| 119 | + } |
| 120 | + { |
| 121 | + category: 'ContainerRegistryLoginEvents' |
| 122 | + enabled: true |
| 123 | + } |
| 124 | + ] |
| 125 | + metrics: [ |
| 126 | + { |
| 127 | + category: 'AllMetrics' |
| 128 | + enabled: true |
| 129 | + timeGrain: 'PT1M' |
| 130 | + } |
| 131 | + ] |
| 132 | + } |
| 133 | +} |
| 134 | + |
| 135 | +output id string = containerRegistry.id |
| 136 | +output loginServer string = containerRegistry.properties.loginServer |
| 137 | +output name string = containerRegistry.name |
0 commit comments