Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Azure WebJob赢得了';t在VS 2015中运行?_C#_.net_Azure_Azure Webjobs - Fatal编程技术网

C# Azure WebJob赢得了';t在VS 2015中运行?

C# Azure WebJob赢得了';t在VS 2015中运行?,c#,.net,azure,azure-webjobs,C#,.net,Azure,Azure Webjobs,我是Azure WebJobs开发的新手,我正在尝试在Visual Studio中测试我的WebJob。我的作业连续运行,但不执行runWebJob()方法?我在host.CallAsync行中指定的。这是我的密码: public class Program { static void Main() { var config = new JobHostConfiguration(); if (config.IsDevelopment)

我是Azure WebJobs开发的新手,我正在尝试在Visual Studio中测试我的WebJob。我的作业连续运行,但不执行runWebJob()方法?我在host.CallAsync行中指定的。这是我的密码:

public class Program {
    static void Main()
    {
        var config = new JobHostConfiguration();

        if (config.IsDevelopment)
        {
            config.UseDevelopmentSettings();
        }
        var host = new JobHost(config);

        host.CallAsync(typeof(Program).GetMethod("runWebJob"));
        // The following code ensures that the WebJob will be running continuously
        host.RunAndBlock();

    }

    [NoAutomaticTrigger]
    public static async Task runWebJob()
    {
        Console.WriteLine("RUNNING METHOD"); 
    }
}

我用你提到的代码进行测试。我们需要设置课程计划公共。那么它应该会起作用

由于异步函数没有等待,我添加了等待测试

public class Program
{
    static void Main(string[] args)
    {

        var config = new JobHostConfiguration();

        if (config.IsDevelopment)
        {
            config.UseDevelopmentSettings();
        }
        var host = new JobHost();

        host.CallAsync(typeof(Program).GetMethod("runWebJob"));
        // The following code ensures that the WebJob will be running continuously
        host.RunAndBlock();

    }
    [NoAutomaticTriggerAttribute]
    public static async Task runWebJob()
    {
        await Task.Delay(1000); //just for test
        Console.WriteLine("RUNNING METHOD");
    }
我在我这边测试

注意:如果将
host.CallAsync(typeof(Program).GetMethod(“runWebJob”))
更改为
host.Call(typeof(Program).GetMethod(“runWebJob”))
并将函数更改为synchronously函数,则可以看到详细错误

更新:

默认情况下,WebJobs SDK查找名为AzureWebJobsStorage和AzureWebJobsDashboard的连接字符串

如果尚未在app.config文件中添加以下连接字符串,请尝试添加。更多详情请参阅



当您尝试运行此应用程序时,控制台输出是什么?根本没有输出。当它运行Microsoft.Azure.WebJobs.JobHost.CallAsync Id=8,Status=WaitingForActivation,Method=“{null}”,Result=“{Not yet computed}”尝试将.Wait()添加到CallAsync()方法的末尾时,我在本地看到了这一点。它无论如何都应该运行,但它是一个异步调用,您需要明确说明您希望它何时完成。@MCooper您的函数不是异步的,它将同步运行,因为它缺少wait关键字。这对我不起作用……我的代码仍然不会运行?这可能是因为我的App.config文件有问题吗?我想做的就是运行这个程序,看看它在VS Studio中是否有效。我已经更新了答案。如果尚未添加AzureWebJobsStorage连接字符串,请将其添加到app.config文件中。如果它不工作,请提供更多信息。Sun MSFT我的App.config文件中有以下内容:
如果您不启动Storage Emulator,请尝试启动它。或者您可以尝试使用Azure存储帐户连接字符串吗?您有关于此线程的任何更新吗?如果有用,请将其标记为一个答案,以帮助更多有相同问题的社区。
 <connectionStrings>
        <add name="AzureWebJobsDashboard" connectionString="DefaultEndpointsProtocol=https;AccountName=[accountname];AccountKey=[accesskey]"/>
        <add name="AzureWebJobsStorage" connectionString="DefaultEndpointsProtocol=https;AccountName=[accountname];AccountKey=[accesskey]"/>
</connectionStrings>