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 in Azure by sabby
• 4,350 points
61 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 by Prerna
• 1,940 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
• 56,900 points
3,053 views
0 votes
1 answer

How can I remove/hide/disable excessive HTTP response headers in Azure/IIS7 without having to use UrlScan?

MSDN published an article on how to ...READ MORE

answered May 21, 2018 in Azure by club_seesharp
• 3,450 points
583 views
0 votes
2 answers

How can I add database connection string to Azure Functions?

The best way to do this is ...READ MORE

answered Aug 17, 2018 in Azure by Priyaj
• 56,900 points
3,588 views
0 votes
1 answer

How can i upload to Azure Blob storage with Shared Access key?

For GetBlobReferenceFromServer to work, the blob must be present ...READ MORE

answered Jun 12, 2018 in Azure by club_seesharp
• 3,450 points
872 views
0 votes
1 answer

How to install Windows Azure Storage Emulator?

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

answered Mar 6 in Azure by Prerna
• 1,940 points
302 views
0 votes
1 answer

Azure Storage Emulator shows error.

This blog might help with your query: http://blog.smarx.com/posts/windows-azure-storage-emulator-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process Also, ...READ MORE

answered Mar 15 in Azure by Prerna
• 1,940 points
160 views
0 votes
1 answer

Friendly filename when downloading Azure blob.

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

answered Mar 15 in Azure by Prerna
• 1,940 points
62 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 in Azure by Prerna
• 1,940 points
447 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 in Azure by Prerna
• 1,940 points
126 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 in Azure by Prerna
• 1,940 points
792 views