Skip to content

Commit

Permalink
Fix values for dockerImageRegistry and dockerImageRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
mburumaxwell committed Sep 27, 2023
1 parent b2918ac commit 8c47f19
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 30 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ The easiest means of deployment is to use the relevant button above. You can als
|azureDevOpsProjectToken|Personal Access Token (PAT) for accessing the Azure DevOps project. It must have `Environment (Read & Manage)` permissions.|Yes|**none**|
|location|Location to deploy the resources.|No|<resource-group-location>|
|name|The name of all resources.|No|`azdo-cleaner`|
|dockerImageRegistry|The docker registry to use when pulling the docker container if needed. By default this will GitHub Container Registry. This can be useful if the container needs to come from an internal docker registry mirror or alternative source for testing. If the registry requires authentication ensure to assign `acrPull` permissions to the managed identity.<br />Example: `contoso.azurecr.io`|No|`ghcr.io`|
|dockerImageRepository|The docker container repository to use when pulling the docker container if needed. This can be useful if the default container requires customizations such as custom certs.|No|`tinglesoftware/azure-devops-cleaner`|
|dockerImageTag|The image tag to use when pulling the docker container. A tag also defines the version. You should avoid using `latest`. Example: `0.1.0`|No|&lt;version-downloaded&gt;|

> The template includes a User Assigned Managed Identity, which is used when performing Azure Resource Manager operations such as deletions. After deployment, you should assign `Contributor` permissions to it where you want it to operate such as a subscription or a resource group. See [official docs](https://learn.microsoft.com/en-us/azure/role-based-access-control/role-assignments-portal-managed-identity#user-assigned-managed-identity) for how to assign permissions.<br/><br/> You can also do the role assignment on a management group. The tool scans for subscriptions that it has access to before listing the resources of a given type so you need not change anything in the deployment after altering permissions.
Expand Down
11 changes: 1 addition & 10 deletions main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ param location string = resourceGroup().location
@description('Name of all resources.')
param name string = 'azdo-cleaner'

@description('Registry of the docker image. E.g. "contoso.azurecr.io". Leave empty unless you have a private registry mirroring the official image.')
param dockerImageRegistry string = 'ghcr.io'

@description('Registry and repository of the docker image. Ideally, you do not need to edit this value.')
param dockerImageRepository string = 'tinglesoftware/azure-devops-cleaner'

@description('Tag of the docker image.')
param dockerImageTag string = '#{GITVERSION_NUGETVERSIONV2}#'

Expand Down Expand Up @@ -44,8 +38,6 @@ param logAnalyticsWorkspaceId string = ''
@description('Resource identifier of the ContainerApp Environment to deploy to. If none is provided, a new one is created.')
param appEnvironmentId string = ''

var hasDockerImageRegistry = (dockerImageRegistry != null && !empty(dockerImageRegistry))
var isAcrServer = hasDockerImageRegistry && endsWith(dockerImageRegistry, environment().suffixes.acrLoginServer)
var hasProvidedServiceBusNamespace = (serviceBusNamespaceId != null && !empty(serviceBusNamespaceId))
var hasProvidedStorageAccount = (storageAccountId != null && !empty(storageAccountId))
var hasProvidedLogAnalyticsWorkspace = (logAnalyticsWorkspaceId != null && !empty(logAnalyticsWorkspaceId))
Expand Down Expand Up @@ -148,7 +140,6 @@ resource app 'Microsoft.App/containerApps@2023-05-01' = {
managedEnvironmentId: hasProvidedAppEnvironment ? appEnvironmentId : appEnvironment.id
configuration: {
ingress: { external: true, targetPort: 80, traffic: [ { latestRevision: true, weight: 100 } ] }
registries: isAcrServer ? [ { identity: managedIdentity.id, server: dockerImageRegistry } ] : []
secrets: concat(
[
{ name: 'connection-strings-application-insights', value: appInsights.properties.ConnectionString }
Expand All @@ -165,7 +156,7 @@ resource app 'Microsoft.App/containerApps@2023-05-01' = {
template: {
containers: [
{
image: '${'${hasDockerImageRegistry ? '${dockerImageRegistry}/' : ''}'}${dockerImageRepository}:${dockerImageTag}'
image: 'ghcr.io/tinglesoftware/azure-devops-cleaner:${dockerImageTag}'
name: 'azdo-cleaner'
env: [
{ name: 'AZURE_CLIENT_ID', value: managedIdentity.properties.clientId } // Specifies the User-Assigned Managed Identity to use. Without this, the app attempt to use the system assigned one.
Expand Down
19 changes: 1 addition & 18 deletions main.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@
"description": "Name of all resources."
}
},
"dockerImageRegistry": {
"type": "string",
"defaultValue": "ghcr.io",
"metadata": {
"description": "Registry of the docker image. E.g. \"contoso.azurecr.io\". Leave empty unless you have a private registry mirroring the official image."
}
},
"dockerImageRepository": {
"type": "string",
"defaultValue": "tinglesoftware/azure-devops-cleaner",
"metadata": {
"description": "Registry and repository of the docker image. Ideally, you do not need to edit this value."
}
},
"dockerImageTag": {
"type": "string",
"defaultValue": "#{GITVERSION_NUGETVERSIONV2}#",
Expand Down Expand Up @@ -96,8 +82,6 @@
}
},
"variables": {
"hasDockerImageRegistry": "[and(not(equals(parameters('dockerImageRegistry'), null())), not(empty(parameters('dockerImageRegistry'))))]",
"isAcrServer": "[and(variables('hasDockerImageRegistry'), endsWith(parameters('dockerImageRegistry'), environment().suffixes.acrLoginServer))]",
"hasProvidedServiceBusNamespace": "[and(not(equals(parameters('serviceBusNamespaceId'), null())), not(empty(parameters('serviceBusNamespaceId'))))]",
"hasProvidedStorageAccount": "[and(not(equals(parameters('storageAccountId'), null())), not(empty(parameters('storageAccountId'))))]",
"hasProvidedLogAnalyticsWorkspace": "[and(not(equals(parameters('logAnalyticsWorkspaceId'), null())), not(empty(parameters('logAnalyticsWorkspaceId'))))]",
Expand Down Expand Up @@ -200,13 +184,12 @@
}
]
},
"registries": "[if(variables('isAcrServer'), createArray(createObject('identity', resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', parameters('name')), 'server', parameters('dockerImageRegistry'))), createArray())]",
"secrets": "[concat(createArray(createObject('name', 'connection-strings-application-insights', 'value', reference(resourceId('Microsoft.Insights/components', parameters('name')), '2020-02-02').ConnectionString), createObject('name', 'notifications-password', 'value', parameters('notificationsPassword')), createObject('name', 'project-and-token-0', 'value', format('{0};{1}', parameters('azureDevOpsProjectUrl'), parameters('azureDevOpsProjectToken')))), if(equals(parameters('eventBusTransport'), 'ServiceBus'), createArray(createObject('name', 'connection-strings-asb-scaler', 'value', if(variables('hasProvidedServiceBusNamespace'), listKeys(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', split(parameters('serviceBusNamespaceId'), '/')[2], split(parameters('serviceBusNamespaceId'), '/')[4]), 'Microsoft.ServiceBus/namespaces/AuthorizationRules', split(parameters('serviceBusNamespaceId'), '/')[8], 'RootManageSharedAccessKey'), '2021-11-01').primaryConnectionString, listKeys(resourceId('Microsoft.ServiceBus/namespaces/AuthorizationRules', format('{0}-{1}', parameters('name'), variables('collisionSuffix')), 'RootManageSharedAccessKey'), '2021-11-01').primaryConnectionString))), createArray()))]"
},
"template": {
"containers": [
{
"image": "[format('{0}{1}:{2}', format('{0}', if(variables('hasDockerImageRegistry'), format('{0}/', parameters('dockerImageRegistry')), '')), parameters('dockerImageRepository'), parameters('dockerImageTag'))]",
"image": "[format('ghcr.io/tinglesoftware/azure-devops-cleaner:{0}', parameters('dockerImageTag'))]",
"name": "azdo-cleaner",
"env": [
{
Expand Down

0 comments on commit 8c47f19

Please sign in to comment.