I am trying to publish an Azure function project from Visual Studio to a brand new Function App in Azure.
Unfortunatly, the publish script only publish one of the two functions to Azure. I do not see any folders about the missing function. I am trying to figure out how to publish both functions in a single Azure function App.
Do I need to change the host.json file? Do I have to change any settings in the project?
I am using the publish to Azure functionnality in Visual Studio. I created a profile connected to my azure account.
Thanks alot,
It looks like the floowing instruction was missing in my csproj file:
<None Update="FunctionName/file">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Doing so creates the correct directory in the fonction App allowing the App to detect the missing functions and displaying them to the portal.
Related
I built a very simple Azure Function in Node.js using Visual Studio Code. I also created a new Function App from the Azure Portal and created a "Staging" deployment Slot. Now I want to deploy my function from Visual Studio Code to this existing Function App and Slot - I can't! I do not find the way to select the Slot, and any deployment will go straight into the default/Production slot.
Is this supported from VS Code? If not, is it possible to do it from VS 2017 (remember that this is a Node.js project) ?
Thanks in advance
Jose
Azure function slot is a preview version. It seems not supported in VS code, after creating a slot in the portal, there will not be a slot option and will be an error in it, like the screenshot. If not, there is normal. May be it's a bug. When deploying, it happens like you mentioned.
In the VS 2017, it works fine, just create the profile and publish your function.
Update:
My function is C#. Currently there is no Node.js function template in VS, but you could create c# function and write the function file with node.js manually and publish to azure function slot.
You could create it like the screenshot below, and set Copy if newer for the function.json and index.js.
Check it in the portal.
I have started with asp.net core 2 web app and I can publish it to App Service from Visual Studio using web deploy.
I've created new clean .net core 2 console app. I'm able to upload it as webjob and run using Azure Portal, but how do I publish it from local command line or Visual Studio?
Basically, I don't care whether it will be published alongside the Web Application or as standalone.
EDIT: I've somehow managed to get the publish dialog by right clicking the project and selecting Publish (not Publish as Azure WebJob) as menioned in the docs. But I still don't know what did the trick. Installing Azure SDK? Adding webjob-publish-settings.json? Adding Setting.job?
Publish .net core as webjob with Azure portal:
As you know:
A WebJob looks for specific file type, for example (.cmd, .bat, .exe, etc…)
To run a .NET Core console application you use the DOTNET command
Therefore, you need to create a file with an extension which is WebJob looking for that executes.
1.You could create a .net core conosole application. After running it, you will have the follow file in your projectname/bin/Debug/netcoreapp2.0
2.Create a run.cmd file under it. And the run.cmd content is as below:
#echo off
dotnet ConsoleApp7.dll
3.To deploy the .NET Core console application to an Azure App Service Web App Web Job access the Azure portal and navigate to the Azure App Service where you will host the WebJob.
Click on the WebJobs link and the Add button.
4.Upload the netcoreapp2.0.zip
5.Once the WebJob is successfuly uploaded, it will render in the WebJob blade. Click on it and you will see the Run button.
6.When you write output to the console using the WriteLine() method, it will show in the Run Details window on KUDU/SCM.
For more detail, you could refer to this article and this one.
Update:(publish with command line)
1.First, download your publish settings file of your webapp from Azure Portal.
2.Prepare the .zip folder you have created.
As David said, you could use WAWSDeploy to publish webjob with command line.
You could download WAWSDeploy with this link.
3.Then go to WAWSDeploy/bin/Debug folder to open the local command line.
Try the following command to deploy the webjob:
WAWSDeploy.exe DotNetCoreWebJobSample.zip [WEBSITE_NAME].PublishSettings /t app_data\jobs\triggered\DotNetCoreWebJobSample /v
Target directory will be app_data\jobs\triggered\[WEBJOB_NAME]. If this web job is a continuously running one, replace triggered with continuous.
Note:you could put the WAWSDeploy.exe and publish settings file and the .zip into a folder. If not, you should give the full path of publish settings and .zip file. So that you could publish webjob successfully.
For more detail about WAWSDeploy, refer to this article.
Make sure your csproj includes correct SDK's:
<Project Sdk="Microsoft.NET.Sdk;Microsoft.NET.Sdk.Publish">
Then just right click on the project in Visual Studio and click publish, select Microsoft Azure App Service and you should see the WebJob publish options:
Also notice that you should use Microsoft.NET.Sdk and not Microsoft.NET.Sdk.Web
If you are using Microsoft.NET.Sdk.Web, Visual Studio assumes that you are deploying to WebSite and not WebJob. The publish dialogs are slightly different for WebSite and WebJob. For example, for WebJob project you can specify WebJob Name.
You might be interested in:
github/aspnet/websdk/issue: WebJob publishing for Microsoft.NET.Sdk.Web
github/aspnet/Mvc/issue: How to publish console app as a WebJob rather than Web App
There is a great articel about Develop and deploy WebJobs using Visual Studio - Azure App Service that covers your question.
Basically after installing the prerequisites (depending on your VS version) you can
Right-click the Console Application project in the Solution Explorer, and then click Publish as Azure WebJob.
I am trying to run an azure function locally in Visual Studio 2017 preview with latest tooling for azure functions. i want to know how to pull function.json as my function works on the azure portal but not locally in VS2017.
Looking forward on how to set iot hub connection endpoint settings in local.settings.json file.
In VS2017 tooling function.json file isn't created manually anymore. Instead, it's being generated at publish time from attributes that you put on your function parameters. In your case you will use EventHubTrigger attribute, see several examples in wiki.
Having an existing function.json, you should copy each property-value pair from the binding to the corresponding property of EventHubTrigger attribute. There's not automated way to do that.
local.settings.json is the container to put your app settings while running function locally from VS. They are just key-value pairs, go copy your settings from the portal if you have them there already. This file has no effect on deployment to Azure.
How does Function App detects if a folder contains Functions?
As an incentive for the upcoming Azure Function Tools for VS, I followed the article here: https://blogs.msdn.microsoft.com/appserviceteam/2017/03/16/publishing-a-net-class-library-as-a-function-app/
I have successfully created Azure Function as a web-app project in Visual Studio, deployed the Function App using ARM template, then deployed the Functions using release step in Visual Studio Team Services.
Here are the contents of my Web App project, 'CustomerERPChange' is the Function that I want to get it showing in Azure.
Web App Project
What I'm expecting to see is the Function appearing in the Function App, but that doesn't seem to be the case..
Looking at Kudu I can confirm that the content of my project has been successfully deployed to the ../wwwroot directory, renaming the 'run.cs' back to 'run.csx' also didn't help.
Any idea and suggestion would be appreciated, thanks!
There are two ways to create function within Functions App,
1) using UI Create function with template of your choice,
2) from KuDu portal,
go to your_app_name.scm.azurewebsites.net,
create a folder in home > site > wwwroot > (function_name),
add run.csx or run.ps1, and function.json file to the newly created folder.
About these files :
run.csx or run.ps1 is a file which will automatically gets called when the function is executed.
function.json is a file which defines your function(either it is a timer or HttpTrigger, or other).
I'm using the AzureContinuousDeployment.11.xaml Visual Studio 2013 Template for CI builds from visualstudio.com to an Azure website and it's working great.
However, I need to keep additional files on the server (the app creates files). If I was using the "Web deploy" method, I'd simply disable the "Remove additional files at destination" property, but I don't see an option for that using the Azure deployment template.
I should be able to add /p:SkipExtraFilesOnServer=True to the MSBuild arguments in the build definition, but it isn't working. Files are still being deleted from the web server when I deploy.
I've also tried creating a publish profile and adding it to the template. It hasn't worked either.
I don't think there is a way to keep app-created files while using visual studio deployment. I suggest you to create an Azure Storage account and store those files in the storage (blob would be good enough). It seams that you are using ASP.net. See more detail at Microsoft Azure Storage Client Library for .NET.