Why Azure WebJobs blade is showing no webjobs - azure

Basically i am curious why the WebJobs blade for my App Service shows 0 webjobs ("You haven't added any WebJobs. Click ADD to get started"). And of course, when i click Add, i get "WebJob cannot be added from portal if development from source control is configured.").
I am following this guide. As with almost any technical guide, things get outdated very quickly and frequently. So i'm trying to following this the best i can.
Note that my snippet (taken from the link) essentially looks like this:
class Program
{
static void Main()
{
config = new JobHostConfiguration();
var host = new JobHost(config);
host.RunAndBlock();
}
}
To paraphrase: I am not see my WebJob under my App Service.
Question:
Based on this link/guide, the WebJob simply exists in the solution. There is the Program.cs (the entry point of the app service/host), and then there is the WebJob itself ( Functions.cs, which has a basic implementation with a QueueTrigger("queue") ). Why is the WebJob not showing up under the WebJobs blade under the App Service?

If you have source control configured with your application, the webjobs should be deployed as part of the source control integration.
Form App Service perspective a webjob is just part of the content of the app.
If you deploy a webjob through the portal and then had a commit to your source control, then the webjob would be removed since it wasn't part of the payload being published by source control.
The right way to do this is to make sure webjobs are part of your solution.
As a workaround, you can deploy webjobs through FTP/FTPS but keep in mind they will be removed the moment source control does the next deployment.
Or you could upload the webjobs directly via the Kudu Console.
Open the Kudu Console by selecting "Advanced Tool" --> "Go" in Your App Service on the Azure Portal then Go to the directory for your webjobs: d:\home\site\wwwroot\app_data\jobs\continuous\{job name} drag and drop the .zip file you prepared to upload your webjob

Related

configBuilder 'Secrets' failed

After the initial attempt to publish my web app to Azure I got the following error. I'm using Visual Studio 2019.
Is there a way to undo the publish?
How do I determine what is missing?
The configBuilder 'Secrets' failed while processing the configuration section 'appSettings'.: 'Secrets' Initialization Error: Method not found: 'System.String Microsoft.Configuration.ConfigurationBuilders.Utils.MapPath(System.String)'.
How do I undo the changes that Publish did within my project:
Approach-1:-
Generally, Azure Web Apps provides back up feature which you may enable in your app to keep a backup of your site. If you are sure that the deployment did not go as planned, you can restore the backup.
Goto App Service -> Choose BackUps
You can see the status of the webapps for every hour as shown here:
Click on Restore icon if needed.
Enter the restore location in Choose a location. Select Create new under the App Service box to restore to a new app. Select Create new beneath the Deployment slot box to restore to a new deployment slot.
You can choose the site configuration as well as per requirements. After providing all these, restore it.
Approach-2:-
Usually after publishing any web app to azure from local, it will be deployed on production server.
You may want to undertake some activity or verification before delivering/after delivering the website to production. You can use deployment slots in this case.
Azure provides non-production deployment slots for each web app, on which we can deploy the website temporarily.
Detailed in article given by #Krishna Kumar.
Create deployment slot by adding a slot under app service as shown:
Alternative Reference: Get publish profile

Run a console app in Azure and see the console output

I want to run a console application and see the output. It's a continuous one; I don't understand the other one.
I've got VisualStudio to deploy a console app to a WebJob, but I absolutely cannot get any output from it.
EDIT: why does the app service get a URL to 'browse' it? It's not a website.
EDIT: under HostingPlan->AppService->Diagnostic settings if I try to create a new diagnostic settings then there is a checkbox called AppServiceConsoleLogs which sounds promising, but it seems to require an Archive to storage account and none is listed even though I've set on up.
If you really published this as a "WebJob," then go to the "WebJobs" section of your AppService -- it's in the Settings section -- and it should display your WebJob in the list. Then right-click on your job and select "Logs." This will open the logs for your job. Click on the "Toggle Output" button and this should show you anything your app wrote to the console.
Edit:
Here is the WebJobs section of an App Service on the Azure Portal. If you Right-click on a specific job, it will show a (non-browser) context menu that gives you access to Logs.
If you have a subscription to Azure DevOps, you will be able to run your console app. Upload your console app and create a pipeline to run a script. Add the command and necessary arguments if any and run the pipeline.
The process may take around 10~15 minutes if you do not have an account with azure DevOps, and less if you have it already. Please follow the steps mentioned in the blog I wrote here and you should be able to run your console app without trouble.
How to run Console Applications on Azure Pipelines
PS: This may not be the best solution but as of now it offers free run of console apps on Azure Pipelines. Hope this helps!
why does the app service get a URL to 'browse' it?
Suppose it's your azure web url cause webjob is host in a web, if not please provide more information.
it seems to require an Archive to storage account and none is listed
even though I've set on up.
Mostly it's because your storage account region is different from your web region, so create a new account with the same region then it will show in the list.
And suppose you want to check the webjob output, the simplest way is the Bryan Lewis way, just check the Logs in the kudu page. Else if you want to save it to storage and view it, go to App Service logs under your web Monitoring, set the Application Logging (Blob) and set the storage account(remember the region should be same or create a new one). Then you will be able to view the log csv file like below.

Function Inside a Webjob Not Showing In Dashboard

I may very well be not understanding how this works, but I thought I was doing pretty good up until now.
I have a Azure Storage Account setup for my WebJob Dashboards.
In the application settings of my WebApp I am setting a Connection String AzureWebJobDashboard of type Custom and it has the connection string to that storage account.
In my Webjob I have the following code:
[FunctionName("ProcessIncomingCustomerQueue")]
public static void ProcessIncomingCustomerQueue([QueueTrigger("incoming-customer")] string message, ILogger logger)
{
When I start the webjob, is acts like it is finding everything correctly.
No error message about needing to configure the AzureWebJobDashboard.
When it starts it finds the function per the log:
But when I click on Functions on the top right it says "No functions are present".
Is that not what that is for, to show the functions that are in the webjobs?
Thank you --
Joe
Azure Functions and Azure Web Jobs are 2 different (but related) technologies.
Web Jobs run as part of your Web App. Azure Functions are running separate from your Web App.
If you want to have an Azure Function, create a Function App Resource in the Azure portal and use either the Web Portal to write your code or create a Azure Function Project in Visual Studio and deploy it to that resource.
You can also use Visual Studio Code and the Function CLI to create Azure Functions.
Find details and quick starts here:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-first-azure-function
https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-your-first-function-visual-studio
https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-first-azure-function-azure-cli

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.

Add Azure WebJob to mobile service hosted in App Service

With the new Azure Mobile App Services in Azure the mobile services apparently gains the same WebJob support as Websites have had for a while.
Following the article Deploy WebJobs using Visual Studio according to the section 'Enable automatic WebJobs deployment with a web project' we should be able to add a web job from a right click on the project. None of these options show up for my mobile service project in VS.
I can add a WebJob project to the solution manually, but this does not add the webjobs-list.json file to my mobile service project as the article suggests.
Does anyone know why the add web job context menu doesn't show when right-clicking on the mobile service project? Or the manual steps required to configure the project and appropriate webjobs-list.json file?
Update:
I have manually added the webjobs-list.json file to the main project by copying the format from another initial template project and adjusted the web job project path in it. Even deploying the mobile service to an azure web app doesn't pick up the web job.
It should work. I just created a new Mobile App, downloaded the quickstart, right-clicked the web project (appname-code), and was able to associate a webjob to the web project. Deployment worked as planned. Did you try that workflow? Did you try adding the webjob through the portal?

Resources