Container registry - ParentResourceNotFound #9645
-
Bicep version Describe the bug
To Reproduce Azure DevOps pipeline
main.bicep targetScope = 'subscription'
@allowed([
'p'
't'
'd'
])
param env string
param projectName string
param resourceLocation string
@allowed([
'F1'
'D1'
'B1'
'B2'
'B3'
'S1'
'S2'
'S3'
'P1v2'
'P2v2'
'P3v2'
'P1v3'
'P2v3'
'P3v3'
])
param appServicePlanSku string
@allowed([
'Basic'
'Standard'
'Premium'
])
param crSku string
param subscriptionName string
resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: 'rg-${env}-we-${projectName}'
location: resourceLocation
//dependsOn: [rgShared]
}
resource rgShared 'Microsoft.Resources/resourceGroups@2021-04-01' = if (env != 'd') {
name: 'rg-x-we-${subscriptionName}'
location: resourceLocation
}
module appServiceShared 'shared.bicep' = if (env != 'd') {
name:'appShared'
scope: rgShared
params: {
subscription: subscriptionName
env: env
appServicePlanSku: appServicePlanSku
crSku: crSku
}
}
module appService 'app.bicep' = {
name: 'app${projectName}'
scope: rg
params: {
applicationName: projectName
env: env
containerRegistryName: appServiceShared.outputs.containerRegistryName
}
} shared.bicep param subscription string
@allowed([
'p'
't'
'd'
])
param env string
@allowed([
'F1'
'D1'
'B1'
'B2'
'B3'
'S1'
'S2'
'S3'
'P1v2'
'P2v2'
'P3v2'
'P1v3'
'P2v3'
'P3v3'
])
param appServicePlanSku string
@allowed([
'Basic'
'Standard'
'Premium'
])
param crSku string
param linuxPlan string = 'linux'
param windowsPlan string = 'windows'
param location string = resourceGroup().location
resource appServicePlanSharedWindows 'Microsoft.Web/serverfarms@2022-03-01' = {
name: 'plan-${subscription}-${env}-${windowsPlan}'
location: location
sku: {
name: appServicePlanSku
}
}
resource appServicePlanSharedLinux 'Microsoft.Web/serverfarms@2022-03-01' = {
name: 'plan-${subscription}-${env}-${linuxPlan}'
location: location
sku: {
name: appServicePlanSku
}
kind: linuxPlan
properties: {
reserved: true
}
}
resource acrResource 'Microsoft.ContainerRegistry/registries@2021-09-01' = {
name: 'cr${env}${subscription}'
location: location
sku: {
name: crSku
}
properties: {
adminUserEnabled: true // TO DO - replace by identity
}
}
output containerRegistryName string = acrResource.name app.bicep @allowed([
'p'
't'
'd'
])
param env string
param applicationName string
//param appServicePlanSharedId string
param containerRegistryName string
param location string = resourceGroup().location
resource sharedPlan 'Microsoft.Web/serverfarms@2022-03-01' existing = {
name: 'plan-devops-t-linux'
scope: resourceGroup('rg-x-we-devops')
}
/* resource acrResource 'Microsoft.ContainerRegistry/registries@2021-09-01' existing = {
name: 'crtdevops'
scope: resourceGroup('rg-x-we-devops')
} */
resource appServiceApi 'Microsoft.Web/sites@2022-03-01' = {
name: 'ase-${applicationName}-api-dotnet-${env}'
location: location
properties: {
serverFarmId: sharedPlan.id
httpsOnly: true
siteConfig: {
linuxFxVersion: 'DOCKER|${containerRegistryName}.azurecr.io/${applicationName}service:latest'
appSettings: [
{
name: 'DOCKER_REGISTRY_SERVER_URL'
value: 'https://mcr.microsoft.com'
}
{
name: 'DOCKER_REGISTRY_SERVER_USERNAME'
value: containerRegistryName
}
{
name: 'DOCKER_REGISTRY_SERVER_PASSWORD'
value: listCredentials(resourceId('Microsoft.ContainerRegistry/registries', containerRegistryName), '2021-06-01-preview').passwords[0].value //acrResource.listCredentials().passwords[0].value
}
{
name: 'WEBSITES_PORT'
value: '7122'
}
]
}
}
}
resource appServiceAngular 'Microsoft.Web/sites@2022-03-01' = {
name: 'ase-${applicationName}-frontend-angular-${env}'
location: location
properties: {
serverFarmId: sharedPlan.id
httpsOnly: true
siteConfig: {
linuxFxVersion: 'DOCKER|${containerRegistryName}.azurecr.io/${applicationName}:latest'
appSettings: [
{
name: 'DOCKER_REGISTRY_SERVER_URL'
value: 'https://mcr.microsoft.com'
}
{
name: 'DOCKER_REGISTRY_SERVER_USERNAME'
value: containerRegistryName
}
{
name: 'DOCKER_REGISTRY_SERVER_PASSWORD'
value: listCredentials(resourceId('Microsoft.ContainerRegistry/registries', containerRegistryName), '2021-06-01-preview').passwords[0].value //acrResource.listCredentials().passwords[0].value
}
]
}
}
}
main.parameters.json {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"env": {
"value": "t"
},
"projectName": {
"value": "myaccount"
},
"resourceLocation": {
"value": "westeurope"
},
"appServicePlanSku": {
"value": "B1"
},
"subscriptionName": {
"value": "devops"
},
"crSku": {
"value": "Basic"
}
}
} Additional context |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Moving this to discussion - I think this will have the same resolution as #9579 |
Beta Was this translation helpful? Give feedback.
Moving this to discussion - I think this will have the same resolution as #9579