本文整理汇总了C#中Microsoft.Azure.WebJobs.JobHost类的典型用法代码示例。如果您正苦于以下问题:C# JobHost类的具体用法?C# JobHost怎么用?C# JobHost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JobHost类属于Microsoft.Azure.WebJobs命名空间,在下文中一共展示了JobHost类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main()
{
// string connectionString =
//ConfigurationManager.ConnectionStrings["RootManageSharedAccessKey"].ConnectionString;
// Action<BrokeredMessage> callback = x =>
// {
// };
// var clients = new List<SubscriptionClient>();
// for (int i = 0; i < 5; i++)
// {
// var client = TopicClient.CreateFromConnectionString(connectionString, "signalr_topic_push_" + i);
// client.
// client.OnMessage(callback);
// clients.Add(client);
// }
// Console.ReadLine();
//var ctx = GlobalHost.ConnectionManager.GetHubContext<yourhub>();
//ctx.Clients.Client(connectionId).< your method >
var cloudStorage = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["DataStorage"].ConnectionString);
var tableClient = cloudStorage.CreateCloudTableClient();
_tickEvents = tableClient.GetTableReference("tickevents");
_tickEvents.CreateIfNotExists();
var host = new JobHost();
var cancelToken = new WebJobsShutdownWatcher().Token;
_eventHubClient = EventHubClient.CreateFromConnectionString(ConfigurationManager.ConnectionStrings["IotHubConnection"].ConnectionString, iotHubD2cEndpoint);
var d2CPartitions = _eventHubClient.GetRuntimeInformation().PartitionIds;
Task.WaitAll(d2CPartitions.Select(partition => ListenForEvent(host, partition, cancelToken)).ToArray(), cancelToken);
host.RunAndBlock();
}
示例2: 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();
}
示例3: Main
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
public static void Main()
{
try
{
#if !DEBUG
LogManager.Logger = new OneTimeLogger(new ProfileRepository());
#endif
LogManager.Log("Start !");
JobHostConfiguration config = new JobHostConfiguration();
config.Queues.BatchSize = 1;
var host = new JobHost(config);
Init();
Run();
#if DEBUG
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
#else
LogManager.Log("This is release !");
// The following code ensures that the WebJob will be running continuously
//host.RunAndBlock();
#endif
}
catch (Exception ex)
{
LogManager.Log(ex);
}
finally
{
LogManager.Log("End");
LogManager.FlushLogger();
}
}
示例4: Main
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
static void Main()
{
var config = new JobHostConfiguration();
config.UseTimers();
var host = new JobHost(config);
host.RunAndBlock();
}
示例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
public int Main(string[] args)
{
var builder = new ConfigurationBuilder();
builder.Add(new JsonConfigurationProvider("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;
}
示例7: Main
static void Main()
{
CreateDemoData();
JobHost host = new JobHost();
host.RunAndBlock();
}
示例8: Main
static void Main()
{
CreateDemoData();
JobHost host = new JobHost();
host.Start();
}
示例9: Main
static void Main()
{
_servicesBusConnectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.ServiceBus);
namespaceManager = NamespaceManager.CreateFromConnectionString(_servicesBusConnectionString);
if (!namespaceManager.QueueExists(nameof(Step1)))
{
namespaceManager.CreateQueue(nameof(Step1));
}
if (!namespaceManager.QueueExists(nameof(Step2)))
{
namespaceManager.CreateQueue(nameof(Step2));
}
JobHostConfiguration config = new JobHostConfiguration();
config.UseServiceBus();
var host = new JobHost(config);
CreateStartMessage();
host.RunAndBlock();
}
示例10: Main
static void Main()
{
CreateDemoData();
JobHostConfiguration configuration = new JobHostConfiguration();
// Demonstrates the global queue processing settings that can
// be configured
configuration.Queues.MaxPollingInterval = TimeSpan.FromSeconds(30);
configuration.Queues.MaxDequeueCount = 10;
configuration.Queues.BatchSize = 16;
configuration.Queues.NewBatchThreshold = 20;
// Demonstrates how queue processing can be customized further
// by defining a custom QueueProcessor Factory
configuration.Queues.QueueProcessorFactory = new CustomQueueProcessorFactory();
JobHost host = new JobHost(configuration);
host.Start();
// Stop the host if Ctrl + C/Ctrl + Break is pressed
Console.CancelKeyPress += (sender, args) =>
{
host.Stop();
};
while(true)
{
Thread.Sleep(500);
}
}
示例11: 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();
}
示例12: Main
static void Main(string[] args)
{
var host = new JobHost();
Console.Error.Write("An error occurred in this web job");
host.RunAndBlock();
}
示例13: Main
static void Main(string[] args)
{
JobHostConfiguration config = new JobHostConfiguration();
//config.Tracing.Trace = new ConsoleTraceWriter(TraceLevel.Verbose);
config.UseRedis();
JobHost host = new JobHost(config);
host.Start();
// Give subscriber chance to startup
Task.Delay(5000).Wait();
host.Call(typeof(Functions).GetMethod("SendSimplePubSubMessage"));
host.Call(typeof(Functions).GetMethod("SendPubSubMessage"));
host.Call(typeof(Functions).GetMethod("SendPubSubMessageIdChannel"));
host.Call(typeof(Functions).GetMethod("AddSimpleCacheMessage"));
host.Call(typeof(Functions).GetMethod("AddCacheMessage"));
host.Call(typeof(Functions).GetMethod("AddCacheMessage"));
Console.CancelKeyPress += (sender, e) =>
{
host.Stop();
};
while (true)
{
Thread.Sleep(500);
}
}
示例14: 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}"
});
}
}
示例15: 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(webjobsConnectionString);
var host = new JobHost(jobHostConfig);
host.RunAndBlock();
return 0;
}