Umbraco Site Fails To Start on Azure Because of wwwroot/media

On trying to deploy and publish a simple Umbraco site onto Azure using Visual Studio. The site will not start due to a 503 error.

In the logs, the following keeps coming up;

Application: w3wp.exe CoreCLR Version: 8.0.1224.60305 .NET Version: 8.0.12 Description: The process was terminated due to an unhandled exception. 
Exception Info: System.IO.DirectoryNotFoundException: C:\home\site\wwwroot\wwwroot\media\ at 
Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters) at 
Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root) at Umbraco.Cms.Core.IO.PhysicalFileSystem.Create() at

The steps I have tried to make this error go away:

  1. create an empty folder called media at wwwroot/wwwroot/media.
  2. create an empty folder called media at wwwroot/media as well.
  3. delete the above two folders
  4. Changing appsettings.json to use Blob Storage using a container I set up specifically for this website.

None of these steps could get rid of the error.

Is this a bug with Azure or is this fixable?

Thanks,

Julius

Have a look at this one:

I would suggest for now you add an empty text file in the media folder and check that into source control, that way, when deploying, it should bundle that into a media folder so that it will always exists on the server.

This doesn’t work, because when you create the text file - Visual Studio tries to delete the text file on deploying it and then it can’t and then the build fails:


Web Deploy cannot modify the file 'media' on the destination because it is locked by an external process.  In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.  Learn more at: https://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.
The process cannot access '\\?\C:\home\site\wwwroot\wwwroot\media' because it is being used by another process.
   at Microsoft.Web.Deployment.NativeMethods.RaiseIOExceptionFromErrorCode(Win32ErrorCode errorCode, String maybeFullPath)

Hmm, must be a way to tell msbuild to try not to do that.

Really though, I’d love to know how this problem even starts, there’s 1000 of people who deploy to azure every day, multiple times that don’t have this problem. So I’m wondering what they’re doing differently from you and the people on the issue tracker. Umbraco Cloud uses Azure appservice too without this problem. Curious… :thinking:

So basically Azure just hates me specifically?

Ensure that the WebPublishMethod in your .pubxml profile is set to ZipDeploy not MSDeploy. Are you targeting a Windows or Linux App service?

When I try ZipDeploy, the task fails unexpectedly. I am targeting a Windows App Service

:\Program Files\dotnet\sdk\9.0.200\Sdks\Microsoft.NET.Sdk.Publish\targets\PublishTargets\Microsoft.NET.Sdk.Publish.ZipDeploy.targets(58,5): Error MSB4018: The "ZipDeploy" task failed unexpectedly.
System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The remote name could not be resolved: 'webforprofessionals.scm.azurewebsites.net'

Make sure your PublishUrl starts with https:// and ends with a / e.g.
<PublishUrl>https://webforprofessionals.scm.azurewebsites.net/</PublishUrl>

I tried changing it and still the same error.

Here is my entire publish profile - can you spot anything wrong:

<

Project>
  <PropertyGroup>
    <WebPublishMethod>ZipDeploy</WebPublishMethod>
    <ResourceId>/subscriptions/d2d15f83-67f3-4220-8689-0f65178eb4ec/resourceGroups/DemoWeb20250304133833ResourceGroup/providers/Microsoft.Web/sites/WebForProfessionals</ResourceId>
    <ResourceGroup>DemoWeb20250304133833ResourceGroup</ResourceGroup>
    <PublishProvider>AzureWebSite</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>https://webforprofessionals-dmayaqa2ekeecfbn.canadacentral-01.azurewebsites.net/</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
    <ExcludeApp_Data>false</ExcludeApp_Data>
    <ProjectGuid>d31a7754-4bec-f453-e04f-f6cec928784e</ProjectGuid>
    <MSDeployServiceURL>https://webforprofessionals-dmayaqa2ekeecfbn.scm.canadacentral-01.azurewebsites.net/</MSDeployServiceURL>
    <DeployIisAppPath>WebForProfessionals</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>false</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <EnableMSDeployBackup>true</EnableMSDeployBackup>
    <EnableMsDeployAppOffline>true</EnableMsDeployAppOffline>
    <UserName />
    <_SavePWD>false</_SavePWD>
    <_DestinationType>AzureWebSite</_DestinationType>
    <InstallAspNetCoreSiteExtension>false</InstallAspNetCoreSiteExtension>
    <TargetFramework>net8.0</TargetFramework>
    <SelfContained>false</SelfContained>
  </PropertyGroup>
  <ItemGroup>
    <!-- Ensure appsettings.json is copied -->
    <None Update="appsettings.json">
      <CopyToPublishDirectory>Always</CopyToPublishDirectory>
    </None>
    <!-- Ensure environment-specific appsettings are copied -->
    <None Update="appsettings.Development">
      <CopyToPublishDirectory>Always</CopyToPublishDirectory>
    </None>
    <None Update="appsettings.Production">
      <CopyToPublishDirectory>Always</CopyToPublishDirectory>
    </None>
    <None Update="appsettings.Staging">
      <CopyToPublishDirectory>Always</CopyToPublishDirectory>
    </None>
    <!-- Ensure bin folder (assemblies) is included -->
    <None Update="bin\**\*">
      <CopyToPublishDirectory>Always</CopyToPublishDirectory>
    </None>
    <!-- Ensure the App_Plugins folder is included -->
    <None Update="App_Plugins\**\*">
      <CopyToPublishDirectory>Always</CopyToPublishDirectory>
    </None>
    <!-- Ensure the umbraco folder is included -->
    <None Update="umbraco\**\*">
      <CopyToPublishDirectory>Always</CopyToPublishDirectory>
    </None>
    <!-- Ensure uSync folder is included -->
    <None Update="uSync\**\*">
      <CopyToPublishDirectory>Always</CopyToPublishDirectory>
    </None>
    <!-- Ensure Views folder is included -->
    <None Update="Views\**\*">
      <CopyToPublishDirectory>Always</CopyToPublishDirectory>
    </None>
    <!-- Ensure wwwroot folder is included -->
    <None Update="wwwroot\**\*">
      <CopyToPublishDirectory>Always</CopyToPublishDirectory>
    </None>
    <!-- Include any other files needed -->
    <None Update="Composer\**\*">
      <CopyToPublishDirectory>Always</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

I would suggest trying to make it as simple as possible, you should only need 4 properties.
e.g.

<Project>
	<PropertyGroup>
		<WebPublishMethod>ZipDeploy</WebPublishMethod>
		<PublishProvider>AzureWebSite</PublishProvider>
		<PublishUrl>https://webforprofessionals.scm.azurewebsites.net/</PublishUrl>
		<UserName>$webforprofessionals</UserName>
	</PropertyGroup>
</Project>

Also in the Azure Portal have you ensured that “SCM Basic Auth Publishing” is enabled for your webapp in the Configuration blade?

I tried enabling SCM Basic Auth Publishing and I changed the pubxml to your suggestion but still got the same error:

C:\Program Files\dotnet\sdk\9.0.200\Sdks\Microsoft.NET.Sdk.Publish\targets\PublishTargets\Microsoft.NET.Sdk.Publish.ZipDeploy.targets(58,5): Error MSB4018: The "ZipDeploy" task failed unexpectedly.
System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The remote name could not be resolved: 'webforprofessionals.scm.azurewebsites.net'

Looks like your SCM is actually
<PublishUrl>https://webforprofessionals-dmayaqa2ekeecfbn.scm.canadacentral-01.azurewebsites.net/</PublishUrl>

You might want to download the publish profile from the Azure Portal to check if the username is correct

It’s the correct username and PublishUrl because it works totally fine when using MSDeploy.

It is only ZipDeploy that doesn’t work.

I think we can conclude the following from this issue:

  1. The Umbraco team needs to look over how Azure reads the media folder: Azure should be able to detect the media folder when it is in wwwroot - my issue has proven that it can’t.
  2. The deployment process to Azure needs to be looked over in further detail as at the moment it is too difficult to get a basic website up and running on it - I have now been trying to do this for one week and have failed and there is nothing obviously incorrect about my configurations.

When these issues are resolved, I am sure that it would be a better experience for everyone looking to get started with Azure.

It generally isn’t this complicated, however I have seen a specific issue with some regions such as Canada that you are using. The issues are generally due to the additional subdomain level.

e.g.
mysite.scm.azurewebsites.net should be mysite.scm.canadacentral-01.azurewebsites.net

When using the Visual Studio publish dialog have you tried to tick the “Deploy as ZIP package” option, this will then use ZipDeploy but hopefully the wizard will validate all the other settings.

I got the error “Request File Too Large” this time.

Ahh, what tier is your Azure Web App? This normally occurs on shared or free tier as Umbraco requires more space to deploy than is allowed on those tiers.

Yeah cheapskate free tier for me - I just wanted to see if I could get it working on free before paying

Umbraco runs pretty well on Free tier once deployed but due to the size of the Zip that’s needed for ZipDeploy it can’t send it…

You can set to B1, deploy, then set back to F but of course you have to do it every time you want to deploy again.

I guess a potential advantage of MSDeploy is that it syncs files one by one instead of sending a Zip so perhaps it will work directly to Free tier.

So thinking about how to get MSDeploy to deploy that media folder or with a text file in it.

Try to add the below to the csproj and create the empty.txt file if you don’t still have it. I’ve just tried this with the current v15 and it worked :folded_hands:

<ItemGroup>
<Content Include="wwwroot\media\**\*">
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</Content>
</ItemGroup>

I tried again with your suggestions and it copied the entire media folder over successfully because I can see it in the files.

However, it now says “boot failed” with the same error message in the logs saying the media file is missing even though it exists in the correct location and all the correct media files for my website are in there.

I’ve tried to replicate but I’ve not been able to do so :pensive_face: