Can I create an Azure Webjob that doesn t use Azure Storage and exposes functions to the dashboard

0 votes

I want to create an Azure Webjob to serve batch processing needs. It should continuously iterate over a SQL Azure database table picking up certain records, performing some operations and then updating the table. I don't require an Azure storage. Can I still expose my methods to the Azure function invocation dashboard? Or are methods that have the Azure storage attributes the only ones that get exposed?

For example, if I have a function:

ShowTotalNumRecordsProcessedToday()

Then I would like to expose and be able to invoke from the dashboard. I've created some public test functions but they don't show in the dashboard.

Can I do this in my scenario?

Apr 1, 2019 in Azure by sabby
• 4,370 points
2,001 views

1 answer to this question.

0 votes

You can take advantage of the WebJobs SDK regardless of whether you use Azure Storage for data or not.

Here is an example of job that uses the SDK for logging but nothing else, this code has been directly written in the browser so there might some errors.:

public static void Main
{
     using(JobHost host = new JobHost())
     {
         // Invoke the function from code
         host.Call(typeof(Program).GetMethod("DoSomething"));

         // The RunAndBlock here is optional. However,
         // if you want to be able to invoke the function below
         // from the dashboard, you need the host to be running
         host.RunAndBlock();
         // Alternative to RunAndBlock is Host.Start and you
         // have to create your own infinite loop that keeps the
         // process alive
    }
}

// In order for a function to be indexed and visible in the dashboard it has to 
// - be in a public class
// - be public and static
// - have at least one WebJobs SDK attribute
[NoAutomaticTrigger]
public static void DoSomething(TextWriter log)
{
    log.WriteLine("Doing something. Maybe some SQL stuff?");
}

However, you will need a storage account to connect the host and the dashboard.

You can also create your own "custom trigger" for SQL or anything else like this:

public static void Main
{
     using (JobHost host = new JobHost())
     {
         host.Start();

         while (!TerminationCondition)
         {
             if (SomeConditionRequiredForTheTrigger)
             {
                 host.Call(typeof(Program).GetMethod("DoSomething"));
             }
             Thread.Sleep(500);
         }

         host.Stop();
    }
}

// In order for a function to be indexed and visible in the dashboard it has to 
// - be in a public class
// - be public and static
// - have at least one WebJobs SDK attribute
[NoAutomaticTrigger]
public static void DoSomething(TextWriter log)
{
    log.WriteLine("Doing something. Maybe some SQL stuff?");
}

answered Apr 1, 2019 by Prerna
• 1,960 points

Related Questions In Azure

0 votes
2 answers

How can I download a .vhd image to my local machine from azure and upload the same to a different azure account?

From the Windows Azure Portal you can ...READ MORE

answered Aug 20, 2018 in Azure by Priyaj
• 58,020 points
13,990 views
0 votes
1 answer

How to install Windows Azure Storage Emulator?

There may be an issue with the ...READ MORE

answered Mar 7, 2019 in Azure by Prerna
• 1,960 points
2,791 views
0 votes
1 answer

Azure Storage Emulator shows error.

Check if you are running BitTorrent/uTorrent or similar ...READ MORE

answered Mar 16, 2019 in Azure by Prerna
• 1,960 points
1,710 views
0 votes
1 answer

Friendly filename when downloading Azure blob.

Azure blobs can be downloaded in four ...READ MORE

answered Mar 16, 2019 in Azure by Prerna
• 1,960 points
3,769 views
0 votes
1 answer

How to debug Azure 500 internal server error?

You can simply turn off custom error in ...READ MORE

answered Mar 29, 2019 in Azure by Prerna
• 1,960 points
4,847 views
0 votes
1 answer

Can I use .NET's HttpClient to hit an Azure Mobile service?

Yes, you can do this by adding ...READ MORE

answered Apr 15, 2019 in Azure by Prerna
• 1,960 points
1,407 views
0 votes
1 answer

Can I use an appsettings.json file in Azure Functions?

Only environment variables are supported for app ...READ MORE

answered Apr 24, 2019 in Azure by Prerna
• 1,960 points
4,970 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP