本文整理汇总了C#中Microsoft.Azure.WebJobs.JobHost.RunAndBlock方法的典型用法代码示例。如果您正苦于以下问题:C# JobHost.RunAndBlock方法的具体用法?C# JobHost.RunAndBlock怎么用?C# JobHost.RunAndBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Azure.WebJobs.JobHost
的用法示例。
在下文中一共展示了JobHost.RunAndBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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
}
}
示例2: Main
static void Main(string[] args)
{
var host = new JobHost();
Console.Error.Write("An error occurred in this web job");
host.RunAndBlock();
}
示例3: 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;
}
示例4: Main
static void Main()
{
var host = new JobHost();
// The following code ensures that the WebJob will be running continuously
var TWITTERAPPACCESSTOKEN = ConfigurationManager.AppSettings["TWITTERAPPACCESSTOKEN"];
var TWITTERAPPACCESSTOKENSECRET = ConfigurationManager.AppSettings["TWITTERAPPACCESSTOKENSECRET"];
var TWITTERAPPAPIKEY = ConfigurationManager.AppSettings["TWITTERAPPAPIKEY"];
var TWITTERAPPAPISECRET = ConfigurationManager.AppSettings["TWITTERAPPAPISECRET"];
var trackersKeywords = ConfigurationManager.AppSettings["TrackerKeywords"];
var pusherAppId = ConfigurationManager.AppSettings["PusherAppId"];
var pusherAppKey = ConfigurationManager.AppSettings["PusherAppId"];
var pusherAppSecret = ConfigurationManager.AppSettings["PusherAppId"];
var pusherChannel = ConfigurationManager.AppSettings["PusherAppId"];
var pusherEvent = ConfigurationManager.AppSettings["PusherAppId"];
var pusherConfig = new PusherConfig {
AppId = pusherAppId,
AppKey = pusherAppKey,
AppSecret = pusherAppSecret,
Channel = pusherChannel,
Event = pusherEvent
};
Auth.SetUserCredentials(TWITTERAPPAPIKEY, TWITTERAPPAPISECRET, TWITTERAPPACCESSTOKEN, TWITTERAPPACCESSTOKENSECRET);
Auth.ApplicationCredentials = new TwitterCredentials(TWITTERAPPAPIKEY, TWITTERAPPAPISECRET, TWITTERAPPACCESSTOKEN, TWITTERAPPACCESSTOKENSECRET);
Program p = new Program();
p.Stream_FilteredStreamExample(trackersKeywords, pusherConfig);
host.RunAndBlock();
}
示例5: Main
static void Main()
{
CreateDemoData();
JobHost host = new JobHost();
host.RunAndBlock();
}
示例6: 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();
}
示例7: 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();
}
示例8: JobHost
static void JobHost()
{
var config = new JobHostConfiguration();
var host = new JobHost(config);
host.RunAndBlock();
host.Start();
}
示例9: Main
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
static void Main()
{
JobHostConfiguration config = new JobHostConfiguration();
config.UseServiceBus();
JobHost host = new JobHost(config);
host.RunAndBlock();
}
示例10: Main
public static void Main(string[] args)
{
// Set up default WebHook logger
ILogger logger = new TraceLogger();
// Set the WebHook Store we want to get WebHook subscriptions from. Azure store requires
// a valid Azure Storage connection string named MS_AzureStoreConnectionString.
IWebHookStore store = AzureWebHookStore.CreateStore(logger);
// Set the sender we want to actually send out the WebHooks. We could also
// enqueue messages for scale out.
IWebHookSender sender = new DataflowWebHookSender(logger);
// Set up WebHook manager which we use for creating notifications.
Manager = new WebHookManager(store, sender, logger);
// Initialize WebJob
var listener = ConfigurationManager.ConnectionStrings["WebHookListener"].ConnectionString;
JobHostConfiguration config = new JobHostConfiguration
{
StorageConnectionString = listener
};
JobHost host = new JobHost(config);
host.RunAndBlock();
}
示例11: Main
static void Main()
{
// setup unobserved exceptions
TaskScheduler.UnobservedTaskException += Program.handleUnObservedExceptions;
// Setup configuration sources.
Configuration = new Configuration()
.AddEnvironmentVariables("APPSETTING_");
var storageCstr = GetConnectionString();
JobHostConfiguration config = new JobHostConfiguration(storageCstr);
config.Queues.BatchSize = 1; //Number of messages parallel processed in parallel. Will need some concurrency check before increasing.
config.Queues.MaxDequeueCount = 4;
config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(15);
JobHost host = new JobHost(config);
Console.WriteLine("Web Job starting..");
// TEST Lines
//ProvisioningLibrary.WebJobController w = new WebJobController(Configuration);
//w.SubmitActionInQueue("8fd8fbfc-8fb6-4e95-ae17-aa4779423cb8", ResourceAction.Start );
// The following code ensures that the WebJob will be running continuously
host.RunAndBlock();
}
示例12: 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();
var slackConfig = new SlackConfiguration();
WebHooksConfiguration webhookConfig;
if(config.IsDevelopment)
{
config.UseDevelopmentSettings();
webhookConfig = new WebHooksConfiguration(3000);
}
else
{
webhookConfig = new WebHooksConfiguration();
}
// These are optional and will be applied if no other value is specified.
/*
slackConfig.WebHookUrl = "";
// IT IS A BAD THING TO HARDCODE YOUR WEBHOOKURL, USE THE APP SETTING "AzureWebJobsSlackWebHookKeyName"
slackConfig.IconEmoji = "";
slackConfig.Username = "";
slackConfig.Channel = "";
*/
config.UseSlack(slackConfig);
config.UseWebHooks(webhookConfig);
var host = new JobHost(config);
// The following code ensures that the WebJob will be running continuously
host.RunAndBlock();
}
示例13: Main
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
static void Main()
{
Console.WriteLine("*************************************************************************");
Console.WriteLine("WebJobUsageHistory:Main starting. DateTimeUTC: {0}", DateTime.UtcNow);
/*/
DateTime sdt = DateTime.Now.AddYears(-3);
DateTime edt = DateTime.Now.AddDays(-1);
BillingRequest br = new BillingRequest("30d4242f-1afc-49d9-a993-59d0de83b5bd",
"72f988bf-86f1-41af-91ab-2d7cd011db47",
sdt, //Convert.ToDateTime("2015-10-28 00:00:00.000"),
edt);//Convert.ToDateTime("2015-10-29 00:00:00.000"));
Functions.ProcessQueueMessage(br);
return;
/**/
JobHostConfiguration config = new JobHostConfiguration();
config.Queues.BatchSize = 3;
config.Queues.MaxDequeueCount = 3;
config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(15);
var host = new JobHost(config);
// The following code ensures that the WebJob will be running continuously
host.RunAndBlock();
}
示例14: Main
public static void Main()
{
var webJobsDashboard = CloudConfigurationManager.GetSetting("AzureWebJobsDashboard");
var webJobsStorage = CloudConfigurationManager.GetSetting("AzureWebJobsStorage");
var storageAcc = CloudConfigurationManager.GetSetting("StorageAccount");
if (string.IsNullOrWhiteSpace(webJobsStorage) || string.IsNullOrWhiteSpace(storageAcc) || string.IsNullOrWhiteSpace(webJobsDashboard))
{
Console.WriteLine("Please add the Azure Storage account credentials ['StorageAccount' & 'AzureWebJobsStorage' & 'AzureWebJobsDashboard'] in App.config");
Console.Read();
return;
}
else
{
var config = new TaskConfiguration()
{
ConnectionString = storageAcc,
StorageElements = new StorageElements(),
};
var factory = new ImageTaskFactory();
foreach (var task in factory.Initialize(config))
{
task.Start();
}
var host = new JobHost();
host.RunAndBlock();
}
}
示例15: 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();
}