I'm testing Azure Functions for the first time using VS 2019 and this guide: https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-your-first-function-visual-studio
When I run the function locally, everything works fine. Then the guide tells me to use VS to publish the app to my Azure account, which I do successfully, and I see a newly created function app in the Azure website:
But if I try to call the function using
https://functionapp220200104024331.azurewebsites.net/api/Function1
as I'm supposed to, I get a 404 error.
If I look at "Functions" at the Azure portal, I see none:
and I think I should see "Function1" there, but it is not listed.
Am I missing something?
It looks like the functions got created successfully, bit did not get published.
The publish flow in Visual Studio first enables you to create a Function App to publish to, but it's only the last 'Publish' step that actually deploys something to Azure. Are you sure you clicked the button labelled 'Publish'?
You can open the 'Web Publish Activity' or 'Microsoft Azure Activity Log' Window under View > Other Windows which should give you some more information on if the publish happened.
You can go to https://functionapp220200104024331.scm.azurewebsites.net (it runs Kudu) to get some more insight into what is and what isn't available.
First, as rickvdbosch says, maybe you don't click the publish button. The Visual Studio create the app service on Azure and wait for you to publish.
Second, Given that the function is not shown under your functionapp, I think this may be a deployment failure. That means you publish to azure but the function is not publish successful. If your function app is created by local. It will publish dll file and the function app will be 'readonly'.
This is your functionapp, you can see there is a plus sign here:
But if you deploy successfully, your function app will be like this:
(Without a plus sign and cannot be edited.)
So I think there is no function under your function app.
You can take the following steps to test my judgment:
If you deploy successful, you will find your function here, a .dll file. But as your description, I think you deploy failed.
Related
I am trying to execute a manually triggered webjob. The system automatically gets failed without showing any proper failed message. I even added application insight to the program but i can't see any failed log in application insight as well.
My main application calls different interfaces and methods from different projects. I have linked all of them by adding references in my main project. I uploaded my webjob simply by using visual studio 2017 feature Publish Azure Webjob
App.config screenshot:
I have couple of connection to Azure file share and one for Database(Microsoft SQL Server)
When I am uploading .exe file from bin>release and then when i am running it this error message is showing up:
The issue is with adding reference to class library from my console application. Although the issue still persist but now at least I know where I am going wrong.
We have reproduced the issue from our end and faced the same problem while deploying the webjob from Visual Studio.
But we have successfully able to run the webjob as you can see in the below attached screenshots for your reference.
Points to be re-checked from your end to publish the webjob to azure app service without any errors:
Make sure after creating the webjob ->open the app.config file in the VS and add the below configuration properties under the <configuration>:
<add name="AzureWebJobsDashboard" connectionString="place your storage account connection string here"/>
<add name="AzureWebJobsStorage" connectionString="place your storage account connection string here"/>
We have used runtime .net framework as Version=v4.7.2 in Visual Studio 2017.
Note: copy and paste the same storage account connection string for both the above properties in app.config file i.e. AzureWebJobsDashboard and AzureWebJobsStorage.
After adding these properties in the app.config file -> save it and right click on the solution explorer tab in Visual studio and build:
Then publish to azure from the solution explorer tab in VS:
Now go to the App Service in azure portal and select webjobs then run the webjob and click on the logs tab to show the results page as shown below:
If the webjob gets successfully deployed then you can see the status as Running like in the below screenshot:
If there are any Errors after the deployment then you can see the error messages by clicking the toggle output screen and troubleshoot based on the error message like below:
I work with several azure functions on a project that I didn't setup on my own, and when I try to publish the project which includes those azure functions to update them, the publishing failed with the following error :
Web deployment task failed. (Connected to the remote computer
("demo.scm.azurewebsites.net") using the Web Management Service,
but could not authorize. Make sure that you are using the correct user
name and password, that the site you are connecting to exists, and
that the credentials represent a user who has permissions to access
the site.
Where do I provide credentials ?
Here are the steps to publish an Azure Function from Visual Studio.
Go to the Azure Portal
Go to your Function App.
Then, select Overview and click Get publish profile and save the file.
Next, go to your Visual Studio project.
Right-click on your Azure Function project.
Select Publish and then Import Profile.
Finally, hit publish.
All the information needed, including your missing credentials, is in that the profile.
I have the exact same issue. Tried to publish and get the exact same error. I did as kzrystof suggested and downloaded the publish profile from the Azure portal and imported it into VS2017. As soon as I pick the publish profile file and click the open button I get the "Publish failed" error message. I checked the output window to find out what the error was, but there is nothing new added to the output. I cleared the output window and clicked the Publish button and immediately receive the "Publish failed" error popup with no further details in the output window.
Update: I was able to successfully publish the Azure Function App by creating a new profile in VS2017 to a new instance up on Azure. I then removed the old instance from the Azure Portal. Successive attempts to publish from VS2017 then worked successfully.
Just as a test, I downloaded the publish profile from the Azure Portal for this new AF app and imported it into VS2017 and still this produces the same "Publish failed" error popup. MS still seems to need to do some work on that scenario.
Also, there still seems to be problems with ZipDeploy so avoid it for now. I keep having timeouts when trying to publish using ZipDeploy. Standard WebDeploy publishes the files individually and thus doesn't have timeout issues.
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.
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).