本文整理汇总了C#中Microsoft.Azure.WebJobs.JobHost.Call方法的典型用法代码示例。如果您正苦于以下问题:C# JobHost.Call方法的具体用法?C# JobHost.Call怎么用?C# JobHost.Call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Azure.WebJobs.JobHost
的用法示例。
在下文中一共展示了JobHost.Call方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
/// <summary>
/// Set up for logging and call our web job functions as appropriate.
/// </summary>
public static void Main()
{
var env = EnvironmentDefinition.Instance;
var timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd_HH:MM");
var logName = $"{env.Name}_report_{timestamp}";
var host = new JobHost();
host.Call(
typeof(DailyReport).GetMethod("SendDailyReport"),
new
{
logName = logName,
log = $"container/{logName}"
});
// We refresh the bot caches every two hours for now. The bots will automatically
// refresh on their own every 8 hours if the webjob fails to run for some reason.
// It's better if we do it here so that user's don't see the latency.
if (DateTime.UtcNow.Hour % 2 == 0)
{
logName = $"{env.Name}_refresh_{timestamp}";
host.Call(
typeof(RefreshCaches).GetMethod("RefreshBotCaches"),
new
{
logName = logName,
log = $"container/{logName}"
});
}
}
示例2: Main
public static void Main(string[] args)
{
JobHostConfiguration config = new JobHostConfiguration();
config.Tracing.ConsoleLevel = TraceLevel.Verbose;
// Set to a short polling interval to facilitate local
// debugging. You wouldn't want to run prod this way.
config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(2);
FilesConfiguration filesConfig = new FilesConfiguration();
if (string.IsNullOrEmpty(filesConfig.RootPath))
{
// when running locally, set this to a valid directory
filesConfig.RootPath = @"c:\temp\files";
}
EnsureSampleDirectoriesExist(filesConfig.RootPath);
config.UseFiles(filesConfig);
config.UseTimers();
config.UseSample();
config.UseCore();
var sendGridConfiguration = new SendGridConfiguration()
{
ToAddress = "[email protected]",
FromAddress = new MailAddress("[email protected]", "WebJobs Extensions Samples")
};
config.UseSendGrid(sendGridConfiguration);
ConfigureTraceMonitor(config, sendGridConfiguration);
WebHooksConfiguration webHooksConfig = new WebHooksConfiguration();
webHooksConfig.UseReceiver<GitHubWebHookReceiver>();
config.UseWebHooks(webHooksConfig);
JobHost host = new JobHost(config);
host.Call(typeof(MiscellaneousSamples).GetMethod("ExecutionContext"));
host.Call(typeof(FileSamples).GetMethod("ReadWrite"));
host.Call(typeof(SampleSamples).GetMethod("Sample_BindToStream"));
host.Call(typeof(SampleSamples).GetMethod("Sample_BindToString"));
host.Call(typeof(TableSamples).GetMethod("CustomBinding"));
// When running in Azure Web Apps, a JobHost will gracefully shut itself
// down, ensuring that all listeners are stopped, etc. For this sample,
// we want to ensure that same behavior when the console app window is
// closed. This ensures that Singleton locks that are taken are released
// immediately, etc.
ShutdownHandler.Register(() => { host.Stop(); });
host.RunAndBlock();
}
示例3: Main
static void Main(string[] args)
{
var host = new JobHost();
Console.WriteLine("EventHubReader has been started at " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:tt"));
host.Call(typeof(Functions).GetMethod("ReadEventHub"));
//host.RunAndBlock();
}
示例4: Main
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
static void Main()
{
var host = new JobHost();
// The following code will invoke a function called ManualTrigger and
// pass in data (value in this case) to the function
host.Call(typeof(Functions).GetMethod("ManualTrigger"), new { value = 20 });
}
示例5: Main
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
private static void Main()
{
var demoMode = (ConfigurationManager.AppSettings["ticketdesk:DemoModeEnabled"] ?? "false").Equals("true", StringComparison.InvariantCultureIgnoreCase);
var isEnabled = false;
var interval = 2;
using (var context = new TdPushNotificationContext())
{
isEnabled = !demoMode && context.TicketDeskPushNotificationSettings.IsEnabled;
interval = context.TicketDeskPushNotificationSettings.DeliveryIntervalMinutes;
}
var storageConnectionString = AzureConnectionHelper.CloudConfigConnString ??
AzureConnectionHelper.ConfigManagerConnString;
var host = new JobHost(new JobHostConfiguration(storageConnectionString));
if (isEnabled)
{
host.Call(typeof(Functions).GetMethod("StartNotificationScheduler"), new { interval});
host.RunAndBlock();
}
else
{
Console.Out.WriteLine("Push notifications are disabled");
host.RunAndBlock();//just run and block, to keep from recycling the service over and over
}
}
示例6: Main
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
static void Main()
{
var host = new JobHost();
// The following code ensures that the WebJob will be running continuously
//host.RunAndBlock();
host.Call(typeof(Program).GetMethod("CreateQueueMessage"), new { value = "Hello world!" });
}
示例7: Main
public int Main(string[] args)
{
var builder = new ConfigurationBuilder();
//builder.Add(new JsonConfigurationSource("config.json"));
builder.AddJsonFile("config.json");
var config = builder.Build();
var webjobsConnectionString = config["Data:AzureWebJobsStorage:ConnectionString"];
var dbConnectionString = config["Data:DefaultConnection:ConnectionString"];
if (string.IsNullOrWhiteSpace(webjobsConnectionString))
{
Console.WriteLine("The configuration value for Azure Web Jobs Connection String is missing.");
return 10;
}
if (string.IsNullOrWhiteSpace(dbConnectionString))
{
Console.WriteLine("The configuration value for Database Connection String is missing.");
return 10;
}
var jobHostConfig = new JobHostConfiguration(config["Data:AzureWebJobsStorage:ConnectionString"]);
var host = new JobHost(jobHostConfig);
var methodInfo = typeof(Functions).GetMethods().First();
host.Call(methodInfo);
return 0;
}
示例8: Main
static void Main()
{
JobHostConfiguration config = new JobHostConfiguration();
var host = new JobHost(config);
host.Call(typeof(Functions).GetMethod("QueueBackup"));
}
示例9: Main
public static void Main(string[] args)
{
JobHostConfiguration config = new JobHostConfiguration();
config.Tracing.ConsoleLevel = TraceLevel.Verbose;
// Set to a short polling interval to facilitate local
// debugging. You wouldn't want to run prod this way.
config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(2);
FilesConfiguration filesConfig = new FilesConfiguration();
if (string.IsNullOrEmpty(filesConfig.RootPath))
{
// when running locally, set this to a valid directory
filesConfig.RootPath = @"c:\temp\files";
}
EnsureSampleDirectoriesExist(filesConfig.RootPath);
config.UseFiles(filesConfig);
config.UseTimers();
config.UseSample();
config.UseCore();
var sendGridConfiguration = new SendGridConfiguration()
{
ToAddress = "[email protected]",
FromAddress = new MailAddress("[email protected]", "WebJobs Extensions Samples")
};
config.UseSendGrid(sendGridConfiguration);
ConfigureTraceMonitor(config, sendGridConfiguration);
WebHooksConfiguration webHooksConfig = new WebHooksConfiguration();
webHooksConfig.UseReceiver<GitHubWebHookReceiver>();
config.UseWebHooks(webHooksConfig);
JobHost host = new JobHost(config);
host.Call(typeof(MiscellaneousSamples).GetMethod("ExecutionContext"));
host.Call(typeof(FileSamples).GetMethod("ReadWrite"));
host.Call(typeof(SampleSamples).GetMethod("Sample_BindToStream"));
host.Call(typeof(SampleSamples).GetMethod("Sample_BindToString"));
host.Call(typeof(TableSamples).GetMethod("CustomBinding"));
host.RunAndBlock();
}
示例10: Main
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
static void Main()
{
var host = new JobHost();
// The following code ensures that the WebJob will be running continuously
Console.WriteLine("starting...");
host.Call(typeof(Program).GetMethod("RunOnce"));
//host.RunAndBlock();
}
示例11: Main
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
public static void Main(string[] args)
{
LogHelper.ConfigureLogging();
Log.Information("Build Number: {buildNumber}", typeof(Program).Assembly.GetName().Version);
var kernel = ConfigureServices();
_dbService = kernel.Get<IDbService>();
var jobHost = new JobHost();
jobHost.Call(typeof(Program).GetMethod("EmailNotificationDaily"));
}
示例12: Main
public static void Main(string[] args)
{
JobHostConfiguration config = new JobHostConfiguration();
FilesConfiguration filesConfig = new FilesConfiguration();
// See https://github.com/Azure/azure-webjobs-sdk/wiki/Running-Locally for details
// on how to set up your local environment
if (config.IsDevelopment)
{
config.UseDevelopmentSettings();
filesConfig.RootPath = @"c:\temp\files";
}
config.UseFiles(filesConfig);
config.UseTimers();
config.UseSample();
config.UseCore();
var sendGridConfiguration = new SendGridConfiguration()
{
ToAddress = "[email protected]",
FromAddress = new MailAddress("[email protected]", "WebJobs Extensions Samples")
};
config.UseSendGrid(sendGridConfiguration);
ConfigureTraceMonitor(config, sendGridConfiguration);
EnsureSampleDirectoriesExist(filesConfig.RootPath);
WebHooksConfiguration webHooksConfig = new WebHooksConfiguration();
webHooksConfig.UseReceiver<GitHubWebHookReceiver>();
config.UseWebHooks(webHooksConfig);
JobHost host = new JobHost(config);
host.Call(typeof(MiscellaneousSamples).GetMethod("ExecutionContext"));
host.Call(typeof(FileSamples).GetMethod("ReadWrite"));
host.Call(typeof(SampleSamples).GetMethod("Sample_BindToStream"));
host.Call(typeof(SampleSamples).GetMethod("Sample_BindToString"));
host.Call(typeof(TableSamples).GetMethod("CustomBinding"));
host.RunAndBlock();
}
示例13: Main
static void Main(string[] args)
{
LogHelper.ConfigureLogging();
Console.WriteLine("Build Number: {0}", typeof(Program).Assembly.GetName().Version);
var kernel = ConfigureServices();
_dbService = kernel.Get<IDbService>();
var jobHost = new JobHost();
jobHost.Call(typeof(Program).GetMethod("EmailNotifications"));
}
示例14: Main
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
static void Main()
{
var host = new JobHost();
host.Call(typeof(Program).GetMethod("ProcessMethod"));
// The following code ensures that the WebJob will be running continuously
host.RunAndBlock();
//TextWriter log = null;
//StorageCredentials credential = new StorageCredentials(ConfigurationManager.AppSettings["AccountName"], ConfigurationManager.AppSettings["AccountKey"]);
//CloudStorageAccount account = new CloudStorageAccount(credential, true);
//UploadToBlog(account, log);
}
示例15: Main
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
static void Main()
{
var host = new JobHost();
var method = typeof(Program).GetMethod("SendWelcome");
host.Call(method, new { dummy = "dummy" });
//var host = new JobHost();
//// The following code ensures that the WebJob will be running continuously
//host.RunAndBlock();
}