The issue has been resolved by changing the file create/update with the following code:
new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)
The problem was probably coming from the CIFS mount implementation.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
My c# .net core 5 application running in azure container environment as azure container app with azure file mounted as a persistent volume suddenly started to throw UnauthorizedAccessException (see below).
It was all working fine until recently. The azure file is setup in read/write access mode and mounts to the container without any issue. The application reads from the volume but when it tries to write only the file is created and then the exception is thrown.
System.UnauthorizedAccessException: Access to the path '/app/Card/IMPORTINTERNATIONAL/EXP_3_20231129_1.XML' is denied.
---> System.IO.IOException: Permission denied
--- End of inner exception stack trace ---
at System.IO.FileStream.WriteNative(ReadOnlySpan`1 source)
at System.IO.FileStream.FlushWriteBuffer()
at System.IO.FileStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.StreamWriter.CloseStreamFromDispose(Boolean disposing)
at System.IO.StreamWriter.Dispose(Boolean disposing)
at System.IO.TextWriter.Dispose()
at PCES.CardService.Web.Controllers.QPCController.<>c__DisplayClass25_0.
The issue has been resolved by changing the file create/update with the following code:
new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)
The problem was probably coming from the CIFS mount implementation.
Hello @Dejan Gjorgjevik - Regarding the below:
The azure file is setup in read/write access mode and mounts to the container without any issue.
Could you elaborate on how it was done? Based on our docs, as far as ACA & Azure Files are concerned for the permission side of things, all that's needed seems to be the following command:
az containerapp env storage set --name my-env --resource-group my-group \
--storage-name mystorage \
--azure-file-account-name <STORAGE_ACCOUNT_NAME> \
--azure-file-account-key <STORAGE_ACCOUNT_KEY> \
--azure-file-share-name <STORAGE_SHARE_NAME> \
--access-mode ReadWrite
This error you're hitting is from the application not having the write permission so please verify that you've run the above, especially given how Read operations are working fine. The following CLI command should show details of your current config:
az containerapp env storage show --name
--resource-group
--storage-name
Also, could you provide more context on whether your app had worked fine as-is and then started throwing this error? or changes were made and the application started throwing this error?
I look forward to your reply.