Unreferenced OWIN DLL seem to be executed at application startup - owin

We are converting a solution to use a new authentication methodology. That methodology includes the OWIN DLLS. I made the changes and pushed them into the Git main branch for testing. This kicked off an automatic build/deploy process to the test environment. However, there was an emergency fix that was need to the original code, so I reverted my commit (that included the OWIN DLLs). I verified the revert really did revert everything. The emergency fix was then made and pushed to main, which again kicked off the build/deploy process.
The emergency deployment did not include the OWIN DLLs in any fashion (no Nuget reference, no proj reference and nothing configured for it in the config files). However, the deployment process does not clean the destination folder before a new deployment. This meant that OWIN DLLs still existed in the deployment folder. When the application (a web app) was run, it reported an error with the OWIN stuff.
This is the list of DLLs that were still in the folder that were not part of the new deployment:
Microsoft.AspNet.Identity.Owin
Microsoft.Owin
Microsoft.Owin.Host.SystemWeb
Microsoft.Owin.Security
Microsoft.Owin.Security.Cookies
Microsoft.Owin.Security.OAuth
Microsoft.Owin.Security.OpenIdConnect
Owin
Once we manually removed those DLLs, the error went away. My question is - if the OWIN DLLs are not referenced by the project how can they run and cause this error?

Related

MSBuilld copies unwanted files from Azure WebJob to another WebJob

We have 2 Azure Webjobs connected to our ASP WebApi application. None of them is using any dependencies from the other one. And yet, after publishing, one of them has executables from the other one. It's worth mantioning that this only happens on publish. Everything is normal on VS build.
This is how files hierachy looks like on Azure FTP
The first one, Deployment, is being published as expected. Those are executables in it's folder:
The second one, EmailSender, has executables from the Deployment:
What's curious, there is also app.publish folder in both of them, containing only one and the same file WebJob.Deployment.exe:
Deployment job works fine. Unfortunately Azure don't recognize EmailSender job, instead it executes Deployment. The only solution that works right now is to manualy delete Deployment's executables directly from FTP, on every publish.
Right now we tried couple of things from SO and blogs, but with no success.
Microsoft.Web.WebJobs.Publish producing duplicate assemblies in deploy package
Azure Webjobs not getting updated after new publish
GitHub solution
Azure Web Job Run Command Incorrectly Set
Edit:
I did accomplished something. It did not resolve the problem, but we don't have app.publish folder anymore. Here is the link to solution on SO. I don't know why we had 'ClickOnce security' options checked for WebJob.Deployment application.
Update:
I run few tests with MSBuild and found something curious. As I said before, Visual Studio Publish works just fine - no additional executables are deployed. But when I run MSBuildprogram (with the same publish profile and project configuration) I got additional Deployment.exe inside EmailsSender folder. This is the command I run:
MSBuild RestAPI.Host.csproj /t:Build /p:Configuration="Develop" /p:Platform="AnyCPU" /p:DocumentationFile="RestAPI.Host.XML" /p:DeployOnBuild="true" /p:PublishProfile="fakebuild_develop.pubxml" /p:OutputPath="backend\build\app\\" /p:SolutionDir="backend\\"
Can someone tell me what's the difference between MSBuild and VS Publish? I cannot find anything usefull on the internet.

What is required for Azure Function Automatic Build and Nuget Restore

This article shows one step closer to an efficient and effective continuous integration workflow for an Azure function. (Thanks to Donna M from Microsoft).
https://blogs.msdn.microsoft.com/appserviceteam/2017/03/16/publishing-a-net-class-library-as-a-function-app/
Rather than re-create our azure functions as web applications, we would like to know exactly what needs to be included in a repository for Kudu or the Azure Function Runtime to automatically perform Nuget Restore and then build the project. Ideally, we could just add whatever is needed to our projects to satisfy the build system.
Previously we had a deploy.cmd script in our repositories according to the Azure Web App convention to orchestrate the restore and build ourselves. It worked in January because Azure Functions are built on web apps, however that has stopped working recently and we found that the folder structure has been rearranged a bit (probably due to the fixes they implemented for locking of .dll files). We understand that deploy.cmd was never officially supported, so we'd just like to know how to modify our existing projects to work in the current version of Azure Functions.
Here's a really good answer on all things nuget & functions deployment:
How can I use NuGet packages in my Azure Functions?
Nuget restore and project build should happen automatically for .csx function apps.
All you need is to follow the folder structure conventions. Here's an example:
Function1/
function.json
run.csx
other.csx
project.json
Function2/
function.json
run.csx
project.json
Shared/
shared.csx
host.json
To make sure that Shared folder code is watched for changes, add Shared to watchDirectories in host.json.

Azure Website Git deployment with 3rd party libs not in nuget

I would like to use Azure git deployment with a product I am working on. We reference a 3rd party library which is privately supplied and not available on Nuget.
Azure syncs with the git repo as you would expect, but when it compiles it fails with errors saying it is unable to find the types within the 3rd party library.
The library is checked in to git in the bin folder.
How can I get Azure to reference this library when compiling?
There should be nothing special about doing this on Azure Web Apps vs doing it locally. If your assembly is committed and you reference it from its committed location, everything should just work.
If it doesn't, please try running through the steps in this document to help identify the issue.
You should be able to use standard NuGet practices to make this work. Looking at the documentation for Package Sources you just need to add the package source (like myget.org) to the nuget.config file place this at the same level as you *.sln file.

Deploying azure webjob via git

I have a solution containing a .net mvc website, and a webjob.
I deploy using git - so on git push to azure, my website is upgraded. I'm now just adding a console application that is going to be run on a schedule. I'm trying to work out how to deploy this with the website when I git push, but I'm not sure how to do this.
I know I could create a folder website\app_data\jobs\triggered\webjob and copy the files into there (say from a post-build event on the webjob), but that would mean I would need to commit all those files to the git repo for the deploy to pick them up - which would also mean that every time I build, Git would be prompting me to commit them again - ugh.
Is there a nicer way to do this - where I can just push my repo to azure, and it will deploy my website correctly AND my webjob?
Thanks
Yes, you can do this without having to put the actual EXE's and project output into the folder explicitly. This blog post from the Azure Blog documents the workaround to enable Git or command-line deployment of a web application inclusive with WebJobs.
http://azure.microsoft.com/blog/2014/08/18/enabling-command-line-or-continuous-delivery-of-azure-webjobs/
If this doesn't unblock you please post an update and I'll help walk diagnose any other issues you run into. You may also want to update the WebJob publishing NuGet to the most updated one on NuGet here: https://www.nuget.org/packages/Microsoft.Web.WebJobs.Publish/1.0.2
As of 9/15/2015, this appears to be as simple as some context menus inside Visual Studio.
If you want your WebJob to automatically deploy whenever your Website is deployed, in Visual Studio you can right-click on the Website and select "Add->Existing Project as Azure WebJob".
More details here, in particular the "Enable automatic WebJobs deployment with a web project" section.
I was struggling with this, but I've got it working now.
It appears that WebJobs.Publish 1.0.2 must be used. 1.0.1 was not working for me. Worked as soon as I updated.
I had also tried adding webjobs.props files as indicated here by David Ebbo, but that didn't work for 1.0.1 and I've now removed those files and it's working under 1.0.2 without them.
Using WebJobs.Publish creates a webjob-publish-settings.json (in the webjob project) and a webjobs-list.json (in the MVC app) and that would seem to be all that is needed.
Only thing that does not work is creating the schedule for a scheduled job. Continuous and Triggered jobs deploy just fine. There's a thread here where David Ebbo mentions that this is a current limitation.

Cleaning the packages folder after deploy

I have an Azure Website configured to deploy from a Bitbucket repository. This works fine.
Since the application is still in active development, I update the nuget packages it uses quite frequently. This causes the packages folder to keep growing indefinitely, unless I go and manually delete the packages.
Now, in my local machine this is not a big issue. Space is cheap. But in Azure, this makes us go over the quota really fast, as old packages accumulate.
How can I customize the Azure deploy process so that it deletes all the packages after a successful deployment?
(I am open to other solutions as well)
You can utilize the custom deployment script feature where you add a step that cleans up the packages directory.
You can read about it here:
http://blog.amitapple.com/post/38418009331/azurewebsitecustomdeploymentpart2/
Another option is to add a post deployment action, by adding a script file (.cmd/.bat) that has the clenup logic to the following directory in your site: d:\home\site\deployments\tools\PostDeploymentActions\, this script will run after the deployment completes successfully.
Read more about it here:
https://github.com/projectkudu/kudu/wiki/Post-Deployment-Action-Hooks

Resources