Why is webjob log not showing proper failed message? - azure

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:

Related

Azure function not found after publishing using Visual Studio 2019

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.

Publishing Azure functions

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.

How to publish asp.net core web job to azure app service

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.

Can't run Azure WebJob ManualTrigger attached to Azure WebSite

I have created an Azure WebSite in Visual Studio. I then added a Azure WebJobs project through Visual Studio. I then provided the connection string to my storage account to both the app.config file of my WebJob project and the web.config file of my WebSite project.
I still cannot get the job to complete successfully. It keeps failing, as I can see that on the Dashboard. When I go to the Dashboard, not only do I see the job failing every time I run it, I also get a red notification that my connection string is incorrect for the AzureWebJobsDashboard. I've provided this connection string in both projects, and I've copied from the Azure Portal, so there is no way I'm getting the connection string wrong.
How can I fix this? I'd like to start creating real WebJobs, but I can't even get the example one to work (the one given to you as a ManualTrigger when you add a WebJob project in Visual Studio).
update
I had forgot to mention that this connection string is also in my application settings in the azure portal already and I still see failures.
Try adding the connection strings on the Application Settings page of your WebApp in azure.
UPDATE
Use a General-purpose storage account to get rid of
System.InvalidOperationException exception.

Reading what is in the vsdiagnostics blob in Azure (1.7)

I've enabled Diagnostics in one of my Worker roles and published it to Azure. There was a new blob container created called "vsdiagnostics" and contained within in are two binary files. I'm assuming that these files contain the output of my Trace statements, but I'm unable to open these files as I have no idea what format they are in.
I've not found anything on www.windowsazure.com about it and most of the tools they recommend are very outdated. I have installed Cerebrata's Azure Diagnostics Manager, but that isn't able to load the Trace Logs.
If anyone could point me in the right direction I'd be grateful!
Most of the time when Visual Studio is used directly with your Windows Azure application, either with deployment or with troubleshooting, it creates a container in your Azure Storage and use this container to get/put data to in between your Azure instance and your Visual Studio instance. Mostly when you see container name start with VS* i.e. VSdeploy or VSDiagnostics, you can take an account that it is related with Visual Studio.
VSdeloy container is used when you deploy your application directly from Visual Studio. First your cspkg is transferred from desktop to this container and then to RDFE.
VSDiagnostics container is used to get the intellitrace data from your Azure Instance to your Visual Studio instance and when blog is downloaded to your desktop and then it is visible in VS as intellitrace logs.
When you opt to view Intellitrace logs, it appears that they are loaded into the vsdiagnostics blob, before being transferred to Visual Studio.

Resources