Search code examples
.netasp.net-coreazure-web-app-serviceweb-config.net-5

.NET 5 - web.config for uploading large files - Azure App Services


To allow large file uploads, the below config is required as a minimum in web.config.

.NET 5/Core doesn’t have a web.config at the time of development.

Is there any way to write the below config to web.config via Azure Pipelines in any automated way?

Direct configuration in the Azure App Service is not an option as we deploy the code multiple times per week.

<configuration>
    <system.webServer>
        <security>
          <requestFiltering>
            <requestLimits maxAllowedContentLength="500000000" />
          </requestFiltering>
        </security>
    <system.webServer>
</configuration>    

Solution

  • To edit your web.config in your CI/CD pipeline, I would recommend taking a look at the File Transform task, which uses XML transformations.

    XML transformations are a pain in my opinion, however, so you could also opt for doing a simple file overwrite using Powershell if you just want to set your web.config to the contents above.

    Also - why not just include the web.config file in your repository? That way, you won't need any CI tasks if you just want a static file & it'll work as expected.