I'm deploying resources in azure using bicep. The deployment process complete successfully without error,
However, the container is not working. In container app log stream (application) I will get the following error:
Connecting to stream...
2025-07-24T04:55:01.48767 Connecting to the container 'hello-template'...
2025-07-24T04:55:01.53411 Kubernetes error happened. Closing the connection.
log stream (system):
Connecting to stream...
{"TimeStamp":"2025-07-24T04:55:49Z","Type":"Normal","ContainerAppName":null,"RevisionName":null,"ReplicaName":null,"Msg":"Connecting to the events collector...","Reason":"StartingGettingEvents","EventSource":"ContainerAppController","Count":1}
{"TimeStamp":"2025-07-24T04:55:50Z","Type":"Normal","ContainerAppName":null,"RevisionName":null,"ReplicaName":null,"Msg":"Successfully connected to events server","Reason":"ConnectedToEventsServer","EventSource":"ContainerAppController","Count":1}
{"TimeStamp":"2025-07-24 04:52:43 \u002B0000 UTC","Type":"Warning","ContainerAppName":"internship-test","RevisionName":"internship-test--s2vnoix","ReplicaName":"internship-test--s2vnoix-66dd654575-5h772","Msg":"MountVolume.SetUp failed for volume \u0022internship-test-volume\u0022 : rpc error: code = Internal desc = volume(csi-d341431304f74d865c98297c5c72c264d7f5b446662947e1f7be4105b5812254) mount //internshipteststacc.file.core.windows.net/internship-test-fileshare on /var/lib/kubelet/pods/fe37caf9-3817-42dd-a811-262d6a8455e2/volumes/kubernetes.io~csi/internship-test-volume/mount failed with mount failed: exit status 32\nMounting command: mount\nMounting arguments: -t cifs -o ,actimeo=30,mfsymlinks,nosharesock,file_mode=0777,dir_mode=0777,\u003Cmasked\u003E //internshipteststacc.file.core.windows.net/internship-test-fileshare /var/lib/kubelet/pods/fe37caf9-3817-42dd-a811-262d6a8455e2/volumes/kubernetes.io~csi/internship-test-volume/mount\nOutput: mount error(2): No such file or directory\nRefer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)\n\nPlease refer to http://aka.ms/filemounterror for possible causes and solutions for mount errors.","Reason":"FailedMount","EventSource":"ContainerAppController","Count":3}
So after seeing this error I delete the volume bicep created, and recreate new one with the same smb file share without any change.
log stream (application) error still the same, but log stream (system) giving new error:
{"TimeStamp":"2025-07-24 05:02:25 \u002B0000 UTC","Type":"Normal","ContainerAppName":"internship-test","RevisionName":"internship-test--0000001","ReplicaName":"internship-test--0000001-5d64cc5cdc-4nmr6","Msg":"The TargetPort 8080 does not match the listening port 80.","Reason":"Pending:PortMismatch","EventSource":"ContainerAppController","Count":4}
So, after I change my ingress target port to 80, the log stream (application) still give same issue, but no error in log stream (system), my container still not work. Surprisingly after I configure the target port back to 8080, now everything work perfectly, my container is working fine.
After further investigation it seem like the only way to solve this problem is to..
recreate the volume in container app manually with the same smb file share
change the ingress target port to 80 then back to 8080
Noted: It should be done in this order else it not gonna work.
Anyone has any better solution? am I just setting up my bicep wrong? or what am I missing.
This is my bicep file (container.module):
param appName string
param location string
param loganalysisId string
param loganalysiskey string
param storageAccountName string
param storageAccountKey string
resource containerRegistry 'Microsoft.ContainerRegistry/registries@2021-06-01-preview' = {
name: '${replace(appName, '-', '')}cr'
location: location
sku: {
name: 'Basic'
}
properties: {
adminUserEnabled: true
}
}
resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' = {
name: '${appName}-cae'
location: 'australiaeast'
properties: {
appLogsConfiguration: {
destination: 'log-analytics'
logAnalyticsConfiguration: {
customerId: loganalysisId
sharedKey: loganalysiskey
}
}
}
}
resource azureFilesStorage 'Microsoft.App/managedEnvironments/storages@2023-05-01' = {
parent: containerAppEnvironment
name: '${appName}-smb'
properties: {
azureFile: {
accountName: storageAccountName
accountKey: storageAccountKey
shareName: '${appName}-fileshare'
accessMode: 'ReadWrite'
}
}
}
resource containerApp 'Microsoft.App/containerApps@2023-05-01' = {
name: appName
location: 'australiaeast'
dependsOn: [
azureFilesStorage
]
properties: {
managedEnvironmentId: containerAppEnvironment.id
configuration: {
ingress: {
external: true
targetPort: 8080
}
registries: [
{
server: containerRegistry.properties.loginServer
username: containerRegistry.listCredentials().username
passwordSecretRef: 'acr-password'
}
]
secrets: [
{
name: 'acr-password'
value: containerRegistry.listCredentials().passwords[0].value
}
]
}
template: {
containers: [
{
name: 'hello-template'
image: 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest'
resources: {
cpu: '0.5'
memory: '1Gi'
}
volumeMounts: [
{
volumeName: '${appName}-volume'
mountPath: '/app/data'
}
]
}
]
volumes: [
{
name: '${appName}-volume'
storageType: 'AzureFile'
storageName: azureFilesStorage.name
}
]
scale: {
minReplicas: 0
maxReplicas: 10
}
}
}
}
bicep file (storage module):
param appName string
param location string
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-02-01' = {
name: '${replace(appName, '-', '')}stacc'
location: location
kind: 'Storage'
sku: {
name: 'Standard_LRS'
}
}
resource fileService 'Microsoft.Storage/storageAccounts/fileServices@2021-09-01' = {
parent: storageAccount
name: 'default'
}
resource fileShare 'Microsoft.Storage/storageAccounts/fileServices/shares@2021-09-01' = {
parent: fileService
name: '${appName}-share'
properties: {
shareQuota: 100
}
}
output storageAccountName string = storageAccount.name
output storageAccountKey string = storageAccount.listKeys().keys[0].value
One thing is that your file share is called:
'${appName}-share'
but the Container App sets the shareName as:
'${appName}-fileshare'