maxshuty maxshuty - 8 days ago 5
JSON Question

Azure Deployment from Visual Studio not deploying a JSON file correctly?

I've deployed my website to Azure, every single thing on the website got deployed just fine except a JSON file which contains a bunch of quotes.

I'm getting a 404 not found error in the console. I've tried redeploying, and that didn't work either.

Here is the output of the deployment (I omitted the boring stuff you don't care about, I left the things you might care about):

1>------ Build started: Project: MyProject, Configuration: Release Any CPU ------
1> Me -> C:\Users\Desktop\MyProject\MyProject\bin\MyProject.dll
2>------ Publish started: Project: MyProject, Configuration: Release Any CPU ------
2>Transformed Web.config using C:\Users\Desktop\MyProject\MyProject\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config.
2>Auto ConnectionString Transformed obj\Release\TransformWebConfig\transformed\Web.config into obj\Release\CSAutoParameterize\transformed\Web.config.
2>Copying all files to temporary location below for package/publish:
2>obj\Release\Package\PackageTmp.
2>Start Web Deploy Publish the Application/package to https://example.scm.azurewebsites.net/msdeploy.axd?site=myuser ...
2>Adding file (user\quotes.json). //<<<<<--- This is the file!
2>Adding file (user\packages.config).
2>Adding file (user\Web.config).
2>Adding ACL's for path (user)
2>Adding ACL's for path (user)
2>Publish Succeeded.
2>Web App was published successfully http://user.example.net/
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========


When I go to the website I just get the 404, it clearly thinks that it's adding the file. Would Azure change the path or something on me? Let me know if you need more information. The deployment process I am doing is through


Visual Studio >> Publish >> Microsoft Azure Web Apps >> MyWebsite >> Publish


The
PublishProfile
looks like this:

<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>http://user.azurewebsites.net</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<MSDeployServiceURL>user.scm.azurewebsites.net:123</MSDeployServiceURL>
<DeployIisAppPath>user</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>$user</UserName>
<_SavePWD>True</_SavePWD>
<_DestinationType>AzureWebSite</_DestinationType>
</PropertyGroup>


When I right click on my
quotes.JSON
file it has an option to Publish it, my instincts told me to click it, so I did... and it returned a nice happy response "Your file(s) have been successfully published." Going back to my site, it's still not there.

Interestingly enough I successfully deployed to another hosting service to test it out, but I cannot use the other service and have to stick to Azure. Clearly something with Azure is being screwy and I'm not sure what it is.

Answer

Well I figured out the solution, and I thought I would leave this question up for anyone else that runs into something similar.

Apparently the other hosting provider I deployed to where everything just...worked... didn't care much about this, but Azure is more fussy and requires this in the Web.config:

 <system.webServer>
     <staticContent>
      <!--For Azure Deployment-->
      <mimeMap fileExtension=".json" mimeType="application/json" />
    </staticContent>
  </system.webServer>

Which makes it blow up when I run on my local machine, but Azure sure loves it.