maxshuty maxshuty - 1 year ago 79
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>Start Web Deploy Publish the Application/package to ...
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
========== 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

looks like this:

<LastUsedPlatform>Any CPU</LastUsedPlatform>
<RemoteSitePhysicalPath />

When I right click on my
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 Source

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:

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

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download