Deploy website to azure with bower dependencies - azure

I have an ASPNET mvc project using both Nuget and Bower for dependencies. Now I need to either trigger bower to install components upon deployment or as fallback include the packages by allowing them in my .gitignore. Of course I would like to not include those in the repo and just have them installed while deploying, just like with nuget packages. I tried to follow this guide http://gregtrowbridge.com/deploying-a-bower-dependent-node-app-on-windows-azure/ but still nothing seems to happen. So any help is welcome :)
Best regards

All of Azure Websites workers have bower pre-installed and should be on your path.
All you need to do is add a custom deployment script that would do bower install
Here is a sample repo for an ASP.NET MVC site that uses bower
Basically make sure bower.json is there and referenced in your csproj
<Content Include="bower.json" />
Then download your custom deployment script. if you go to https://<yourSiteName>.scm.azurewebsites.net then click on Tools -> Download custom deployment script or just download it from D:\home\deployment\tools then check it in the root of your repo like here basically there will be 2 files deploy.cmd and .deployment
this is the deployment logic, add a step to restore bower in it like here after the last step there
:: 4. Bower Install
if EXIST "%DEPLOYMENT_TARGET%\bower.json" (
pushd "%DEPLOYMENT_TARGET%"
call :ExecuteCmd bower install
IF !ERRORLEVEL! NEQ 0 goto error
popd
)

You can use the console feature of Azure web app to fire the commands. Even if the console has access to a restricted features, you can still install the bower components by using the command:
bower install
The console option is listed under the deployment section of the Web Apps. You can refer the below the screen for reference.
Prerequisites:
Do not publish the bowerComponents folder to the Web app.
Include the bower.json file including all the dependencies.
Hope it helps.

One important addition to the above - you must push both the unchanged .deployment file and modified .cmd file to deployment root for Azure to subsequently copy/execute your .cmd amendments. Otherwise it will regenerate a default .cmd

Related

Cannot pack fork of azure-activedirectory-library-for-dotnet into nuget package

I made a fork of the library azure-activedirectory-library-for-dotnet and tried to pack it into a nuget package but failed.
I run the following command on the Developer Command Prompt to try to pack my fork into a nuget package.
nuget Pack src\Microsoft.IdentityModel.Clients.ActiveDirectory\Microsoft.IdentityModel.Clients.ActiveDirectory.csproj
And this is the error I get when I run this command:
Unable to find 'bin\Debug\Microsoft.IdentityModel.Clients.ActiveDirectory\bin\Debug\'. Make sure the project has been built.
But the project is build succesfull and contains the following folder in the debug folder:
My fork github page
The page where the original azure project is stored: Github azure
Link to issue I created on the github page: Issue

Using WebDeploy with an Azure node website doesn't trigger npm install

I am using WebDeploy to deploy a node website to azure.
I've seen in samples and demos that it should trigger a npm install on deploy.
But it is not. I've also seen almost every demo uses git deployment.
Is automatic npm install not supported for WebDeploy or am I missing something?
when you use WebDeploy, it will just copy over all the file from your machine to cloud, it will not trigger any build process. You will have to responsible to make sure your app is ready to run.
if you want CI function, please setup continues deployment, here is tutorial for setting up local git
https://azure.microsoft.com/en-us/documentation/articles/web-sites-publish-source-control/
and there are other options if you have repository in github/bitbucket/Visual studio Team Service etc ... (go to https://portal.azure.com, select your site --> all settings --> continuous deployment to see all supported optinos)
According to the doc Publish to Microsoft Azure Website using Web Deploy, it said
Deployment will include all the files in your project. Files in the node_modules folder are included automatically, even if they are not part of the project.
So all files under your project folder in VS, including the node_modules folder, will be deployed.

How to deploy an Azure Go web app via git push with private repositories as dependencies?

What would be the proper way to deploy a Go app to Azure that have private GitHub repositories as dependencies? Here's the current error from Kudu:
Resolving dependencies
# cd .; git clone https://github.com/my/privaterepo
D:\local\Temp\8d315fa89272e69\gopath\src\github.com\my\privaterepo
Cloning into 'D:\local\Temp\8d315fa89272e69\gopath\src\github.com\my\privaterepo'...
fatal: could not read Username for 'https://github.com': Bad file descriptor
package github.com/my/privaterepo/pkg1: exit status 128
package github.com/my/privaterepo/pkg2: cannot find package $GOROOT)
Building Go app to produce exe file
azureapp\file.go:8:2: cannot find package "github.com/my/privaterepo/pkg1"
in any of:
D:\Program Files\Go\1.5.1\src\github.com\my\privaterepo\pkg1 (from $GOROOT)
I was previously deploying via FTP with web.config's HttpPlatformHandler entry. But using git push is quicker especially for non-Windows team members.
Thanks
As #Not_a_Golfer and #Xiaomin said, vendoring the dependencies worked, here's what I did:
Turned the env variable on locally GO15VENDOREXPERIMENT=1
Installed godep => go get github.com/tools/godep
Making sure your app is passing a go build & go test
Ran godep save this copied all dependencies to ./vendor
On my Azure web app, I also set the environment variable GO15VENDOREXPERIMENT=1
git pushed and voila.
At first I did not set the environment variable on my Azure app, so the dependency resolver was not looking in ./vendor, turning it to 1 fixed everything.

NPM errors and control in Azure Websites

I want to build my Node.JS application in a Azure Website.
There will be an usage of different NPM packages via my packages.json file.
My problem is that I often receive error messages which are related to missing NPM files.
Normally I put my files via FTP or edit them per VS Studio 15 Azure plugin directly on the server. This may be the reason why NPM isn't triggering as Microsoft intended it.
I would prefer a way in which I can just run commands with elevated privileges to have full control over NPM by myself.
Which ways are possible to avaid these problems?
If you're publishing your nodeJS application 'manually' via FTP there are little concerns about that.
First of All, 'manually' means manually.
Git
If you use continuous deployment via Git the final deployment step is to call npm install in your current application folder, this will install all the packages listed in package.json file.
The node_modules folder is excluded by default in .gitignore file, so all packages are downloaded by the server
Web deployment
If you're using web deployment from visual studio or command line, all the files contained by your solution are copied to Hosting environment including node_modules folder , because of this the deployment would take a long time to finish due the huge amount of dependencies and files that the folder contains.
Even worst: this scenario could take you to the same scenario you're facing right now.
FTP deployment
You're copying everything yourself. So the same thing occurs in Web Deployment is happen in FTP deployment method.
--
The thing is that when you copy all those node_modules folder contents you're assuming that those dependencies remains the same in the target enviroment, most of the cases that's true, but not always.
Some dependencies are platform dependent so maybe in you're dev environment a dependency works ok in x86 architectures but what if your target machine or website (or some mix between them) is x64 (real case I already suffer it).
Other related issues could happen. May be your direct dependencies doesn't have the problem but the linked dependencies to them could have it.
So always is strongly recommended to run npm install in your target environment and avoid to copy the dependencies directly from your dev environment.
In that way you need to copy on your target environment the folder structure excluding node_modules folder. And then when files are copied you need to run npm install on the server.
To achieve that you could go to
yoursitename.scm.azurewebsites.net
There you can goto "Debug Console" Tab, then goto this directory D:\home\site\wwwroot> and run
npm install
After that the packages and dependencies are downloaded for the server/website architecture.
Hope this helps.
Azure tweak the Kudu output settings, in local Kudu implementations looks the output is normalized.
A workaround -non perfect- could be this
npm install --dd
Or even more detailed
npm install --ddd
The most related answer from Microsoft itself is this
Using Node.js Modules with Azure applications
Regarding control via a console with elevated privileges there is the way of using the Kudu console. But the error output is quite weird. It's kind of putting blindly commands in the console without much feedback.
Maybe this is a way to go. But I didn't tried this yet.
Regarding deployment it looks like that Azure wants you to prefer Continuous Deployment.
The suggested way is this here.

Getting Blade to work with Meteor on Windows 8

I installed Meteor for Windows via this MSI installer. Now I would like to get Blade working with it. I read through this tutorial in the Blade docs, but atmosphere/meteorite doesn't seem to work with Windows.
Is there a workaround?
Have you got meteor working? There is a manual way, ive not tried it before but it should work.
Install the blade module with npm npm install blade.
Clone the blade git repo and place the meteor subdirectory in meteors package directory, rename it to blade ( I think its C:\Program Files\Meteor\packages (but you'd have to check that directory)
Edit the files in the files in the blade directory to reference the files in the blade npm module correctly. In linux/unix this bit is easy because you could just symlink directly it into packages without copying the folders in and re referencing the files.
Finally go to your meteor project and run meteor add blade and it should be good to go.

Resources