Can'not able to modify a file after publish my .net core API to azure app service FronEnd I'm Using Angular

Mehdi Hasan 0 Reputation points

I'm unable to edit file using C# code .Net 5 inside wwroot folder in azure app service. Is it possible to Edit file Inside wwroot folder using C# code .Net.

Not .rld only any file in wwroot folder .net core app. I'm able to edit it when I run my .net core app locally even it works when i publish it to another server . but after publish azure app service it can't able to edit the text file .
It shows 500 error.


QRCodeGeneratorHelper.DownloadRdlcFileFromAzureStorage Code :

public static void DownloadRdlcFileFromAzureStorage(string connectionString, string containerName, string blobName, string localFilePath)
        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
        CloudBlobContainer container = blobClient.GetContainerReference(containerName);
        CloudBlockBlob blob = container.GetBlockBlobReference(blobName);

        using (var fileStream = File.OpenWrite(localFilePath))

Full Code :

            int extension = 1;
            string mimtype = $"";
            var prescription = await _prescriptionRepo.GetPriscriptionById(id);
            //Azure Blob
            string connectionString = "connectionstringhere";
            string containerName = "namehere";
            string blobName = "report/prescription.rdl";
            var localRdlcFilePath = Path.Combine(Path.GetTempPath(), "prescription.rdl");
            QRCodeGeneratorHelper.DownloadRdlcFileFromAzureStorage(connectionString, containerName, blobName, localRdlcFilePath);
            List<ImageStorage> datasrc2 = new()
            new ImageStorage() {Id=1,Image = GenerateQrCode("")},
            // End Of QR code

            var pres = _mapper.Map<GetPrescriptionForReport>(prescription);
            Dictionary<string, string> parameter = new Dictionary<string, string>
            { "patientname", $"{prescription.Patient.FirstName} {prescription.Patient.LastName}" },
            { "prescriptionid", $"{prescription.PatientId}" },
            { "advice", $"{prescription.Note}" },
            { "doctorname", $"{prescription.DoctorFirstName} {prescription.DoctorLastName}" },
            //{"image", imagae}
            LocalReport localReport = new LocalReport(localRdlcFilePath);
            localReport.AddDataSource("DataSet1", pres.MedicineForPrescription);
            localReport.AddDataSource("DataSet2", datasrc2);
            var result = localReport.Execute(RenderType.Pdf, extension, parameter, mimtype);
            var foo = File(result.MainStream, "application/pdf");
            foo.FileDownloadName = $"{prescription.PatientId}-{prescription.Patient.FirstName} {prescription.Patient.LastName}.pdf";
            return foo;
        catch (Exception ex)
            // Log or handle the exception appropriately

Detailed Question Bellow Link.

Microsoft Technologies based on the .NET software framework.
2,302 questions
A set of technologies in the .NET Framework for building web applications and XML web services.
3,760 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,032 questions
{count} votes

1 answer

Sort by: Most helpful
  1. VenkateshDodda-MSFT 14,206 Reputation points Microsoft Employee

    @Mehdi Hasan Thanks for reaching out to Microsoft Q&A, apologize for any inconvenience caused on this.

    Based on the shared information, I understand that you want to know How to edit the files that were present under the wwwroot folder of your app service. Correct me if my understanding in wrong.

    Irrespective of operating system it is hosted either in Windows based or Linux based app service plan. By default, you can edit the contents inside wwwroot folder using Advanced Tools (Kudu console).

    You can access the Kudu console by requesting to this URL https://<app-name> in the browser.

    • If your app is running windows based app service plan, then you will have either CMD\Powershell to edit or update the files in the app service file system.
    • If your app is running in Linux based plan then you can use either SSH\Bash to edit or update the files.

    Refer to this documentation to know more information about KUDU console.

    Alternatively, you can also use App service editor(provides in-browser-editing experience of your app code) which is available in windows-based app service plans as shown below.

    User's image

    Feel free to reach back to me if you have any further questions on this.

    0 comments No comments