Missing server.js/app.js files, web.config is not generated - node.js

I'm using the source control feature of Windows Azure Mobile Services to push custom API scripts.
What I did:
Cloned the git repository. (It contained a bunch of directories with readme.md files explaining what goes where, and some config files for existing tables' permissions.)
Added service/api/test.js and service/api/test.json files (custom API script and config).
Committed and pushed changes to remote.
I got the following output from git:
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '1cbfbd5ac1'.
remote: Running custom deployment command...
remote: Running deployment command...
remote: Handling Basic Web Site deployment.
remote: KuduSync.NET from: 'D:\home\site\repository\service' to: 'D:\home\site\wwwroot\App_Data\config\scripts'
remote: Copying file: 'api\test.js'
remote: Copying file: 'api\test.json'
remote: Missing server.js/app.js files, web.config is not generated
remote: Node.js versions available on the platform are: 0.6.17, 0.6.20, 0.8.2, 0.8.19, 0.8.26, 0.10.5, 0.10.18, 0.10.21, 0.10.24.
remote: Selected node.js version 0.10.24. Use package.json file to choose a different version.
remote: npm WARN package.json myservice#1.0.0 No repository field.
remote: npm WARN package.json myservice#1.0.0 No README data
remote: Finished successfully.
remote: Deployment successful.
Now when I try to access any of the existing tables through the standard API (e.g. posting to https://myservice.azure-mobile.net/tables/MyTable), I get back a 500 Internal Server Error.
I think this line in the above output has something to do with it:
remote: Missing server.js/app.js files, web.config is not generated
However, there was never any server.js or app.js included in the git repo and I have no idea what those files should contain as there appears to be no mention of these files in the documentation.

It turns out that this error message is not the culprit:
remote: Missing server.js/app.js files, web.config is not generated
Like a good programmer, I had placed configuration information in <PROJECT_ROOT>/shared/config.json. When I checked the log, it complained about a route not being configured properly. The documentation implies that only the <PROJECT_ROOT>/api contains custom routes, so I don't know why it interprets JSON files in the shared directory as route configuration when the documentation clearly states that the shared directory is specifically for shared code used by table and custom API scripts.
After changing it from config.json to config.js and making the necessary code changes, it all started working again.
I still get the warning about missing server.js/app.js files, but it doesn't seem to affect anything.
Conclusion: Don't add JSON files to Azure Mobile Services scripts other than as specified in the readme.md files initially bundled with the scripts.

Related

How to specify build configuration when using local git to publish to Azure

I would like to use local git to publish a project to Azure.
I need to specify the *.csproj (there are multiple projects in my solution) and build configuration (debug/release/etc.).
I only see how to specify the project here.
How can I also specify the build configuration?
You can use the parameter SCM_BUILD_ARGS. Here is the documentation.
e.g. via a .deployment file:
[config]
SCM_BUILD_ARGS=-p:configuration=myconfig
PROJECT=WebApi.csproj
Which will result in a build log like this:
remote: Copying file from "C:\home\site\repository\obj\myconfig\net5.0\PubTmp\Out\WebAPI.dll" to "C:\local\Temp\8d93f0d60e8e884\WebAPI.dll".
remote: Copying file from "C:\home\site\repository\obj\myconfig\net5.0\PubTmp\Out\WebAPI.exe" to "C:\local\Temp\8d93f0d60e8e884\WebAPI.exe".
remote: Copying file from "C:\home\site\repository\obj\myconfig\net5.0\PubTmp\Out\WebAPI.pdb" to "C:\local\Temp\8d93f0d60e8e884\WebAPI.pdb".
remote: Copying file from "C:\home\site\repository\obj\myconfig\net5.0\PubTmp\Out\WebAPI.runtimeconfig.json" to "C:\local\Temp\8d93f0d60e8e884\WebAPI.runtimeconfig.json".

Azure App Service build fails due to error MSB3191: Unable to create directory

Platform: Azure App Service
Deployment: Local Git
Version: .NET 5
When deploying updates (git push to remote Local Git in Azure) .NET 5 Razor Pages app to Azure App Service, the KUDU build fails with the error below. I can solve the problem by using the Console in the Azure Portal to manually delete the entire /obj directory, then the build succeeds. But ideally this would not be necessary every time I need to push an update. Is there a simple way to prevent this error?
Error in terminal after "git push" to remote:
remote: RazorCoreGenerate:
remote: Removing directory "obj\Release\net5.0\Razor\".
remote: Creating directory "obj\Release\net5.0\Razor\Areas\Identity\Pages\Account\".
remote: D:\Program Files (x86)\dotnet\sdk\5.0.201\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(146,5): error MSB3191: Unable to create directory "obj\Release\net5.0\Razor\Areas\Identity\Pages\Account\". Could not find a part of the path 'obj\Release\net5.0\Razor\Areas\Identity\Pages\Account\'. [D:\home\site\repository\abc.csproj]
remote: Done Building Project "D:\home\site\repository\abc.csproj" (default targets) -- FAILED.
remote:
remote: Build FAILED.
remote:
remote: "D:\home\site\repository\abc.csproj" (default target) (1:7) ->
remote: (RazorCoreGenerate target) ->
remote: D:\Program Files (x86)\dotnet\sdk\5.0.201\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(146,5): error MSB3191: Unable to create directory "obj\Release\net5.0\Razor\Areas\Identity\Pages\Account\". Could not find a part of the path 'obj\Release\net5.0\Razor\Areas\Identity\Pages\Account\'. [D:\home\site\repository\abc.csproj]
remote:
remote: 0 Warning(s)
remote: 1 Error(s)
remote:
remote: Time Elapsed 00:01:54.09
remote: Failed exitCode=1, command="D:\Program Files (x86)\MSBuilds\16.8.3\MSBuild\Current\Bin\MSBuild.exe" /restore "D:\home\site\repository\abc.csproj" /p:DeployOnBuild=true /p:configuration=Release /p:publishurl="D:\local\Temp\8d9118005db4f8f"
remote: An error has occurred during web site deployment.
(My apologies in advance. This is my first question ever posted on stackoverflow)
1. Check the folder permission.
2. Open cmd tool as Administrator, then re-run your command.
If you use command in visual studio tools, you also need to run Visual Studio as an administrator.

Azure nodejs dist directory "Error: EBUSY" or files silently not overriden

We have a nodejs - express, angular app. The express app and Angular app are built separately, and the Angular is added into a static/ directory under the express app. In this formation, both are moved into a dist directory to be run using node. It is deployed to Azure and runs under a Windows server (not my choice).
If the deploy script deletes the dist/ directory it fails with
...
remote: > bottal#1.0.0 clear:dist D:\home\site\wwwroot
remote: > rimraf dist
remote:
remote: D:\home\site\wwwroot\node_modules\rimraf\bin.js:47
remote: throw er
remote: ^
remote:
remote: Error: EBUSY: resource busy or locked, rmdir 'D:\home\site\wwwroot\dist'
If the dist directory is not deleted then the deploy silently fails by not overwriting the files.
Is there a best way to write such apps?
This was fixed in 2 ways.
Delete the directory in the Azure deploy.sh (specified in .deployment file)
Instead change to using zip deploys instead of git local (whoops, I didn't say that above).
Both solve the problem, however what made the zip deploy the solution was because the npm install (download and install of dependencies) seemed almost instant compared to when being performed in a git local deploy. We were in a bit of a hurry to keep moving forward (after wasting so much time on what should not have been a problem) that I didn't put any investigation time in to this. It would be interesting to know if it is true, however.d

Azure KUDU deployment ignores project setting when deploy.cmd is specified

I have a custom .deployment file in my nodeJS repo that looks like this:
[config]
project = src/portal
command = deploy.cmd
If I remove the command setting, the project setting is respected. However, I need the custom deploy script to execute some bower and grunt commands. Whenever I add the command parameter back in, Azure/KUDU seems to ignore the project setting. I have reverted to the default deploy.cmd script generated using azure site deploymentscript --node to ensure that my customizations aren't the issue. The problem remains. Am I missing something?
For reference, here's the KUDU output from azure:
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '3f92585db0'.
remote: Running custom deployment command...
remote: Running deployment command...
remote: Handling node.js deployment.
remote: KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
remote: Looking for app.js/server.js under site root.
remote: Missing server.js/app.js files, web.config is not generated
remote: The package.json file does not specify node.js engine version constraints.
remote: The node.js application will run with the default node.js version 0.10.32.
remote: Finished successfully.
remote: Deployment successful.
This is by design, when you have a custom deployment script you have full control over the deployment and so the project property has no meaning.
If you need a different project simply update the custom deployment script with what you need.

Error deploying a node/Express app on Windows Azure

I'm currently trying to deploy an Express/Node.js app on azure without much success -- the error I'm getting is the following:
remote: > libxmljs#0.9.0 install D:\home\site\wwwroot\node_modules\libxmljs
remote: > node-gyp rebuild
remote:
remote:
remote: D:\home\site\wwwroot\node_modules\libxmljs>node "D:\Program Files (x86)\npm\1.3.11\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
remote: Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
remote: MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere. [D:\home\site\wwwroot\node_modules\libxmljs\build\binding.sln]
remote: gypnpm ERR! weird error 1
remote: Failed exitCode=1, command="D:\Program Files (x86)\nodejs\0.10.21\node.exe" "D:\Program Files (x86)\npm\1.3.11\node_modules\npm\bin\npm-cli.js" install --production
remote: An error has occurred during web site deployment.
remote: npm
I recognize that the Azure instance is failing to compile libxmljs, so I've excluded libxmljs from the .gitignore file, which looks like the following:
!/node_modules/
/node_modules/*
!/node_modules/express/
!/node_modules/libxmljs/
.DS_Store
._*
But that's still not helping at all, I suspect because I'm compiling it on a Mac and trying to upload it to a Windows machine. Does anyone have any wisdom for me? Thanks!
Have you tried removing all /node_modules/ from .gitignore entirely?
Also, if you are using a generated .gitignore file, check for the actual "express" folder being ignored. I had to remove that from a Visual Studio generated .gitignore to get continuous integration working with a node.js app and Azure.
If no amount of .gitignore massaging works, try FTP'ing all of your project files up to the server manually to see if it kicks over. This will tell you if it's an issue with continuous integration/Git or with the actual app and environment.
Edit: On the subject of finicky node.js deployments to Azure I have also experienced trouble due to my app's directory structure.

Resources