Azure webjobs失败[访问被拒绝] [英] Azure webjobs failed [Access is denied]

查看:73
本文介绍了Azure webjobs失败[访问被拒绝]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个控制台应用程序来读取gmail收件箱.我需要我的控制台应用程序每15分钟阅读一次电子邮件.因此,我以运行方式:按需"将web控制台应用程序发布为webjobs,并使用azure服务发布了该应用程序(网络应用程序).

I created a console application to read gmail inbox.I need my console app to read emails every 15 minutes.So i published the console app as webjobs with runmode : "On demand" and published the app using azure services (web apps).

但是我的webjobs似乎没有运行,并且当我选择发布为天蓝色的webjobs"时,没有选择安排webjob的选项.

But my webjobs doesn't seem to run and there is no option to schedule a webjob when i select publish as azure webjobs.

发布后,我就会在Visual Studio中收到此错误:

As soon as i publish i get this error in visual studio :

'ICICIEmailParser.sstageEntities-Web.config Connection String' argument cannot be null or empty

webjob没有计划的时间,因此我从azure门户手动运行了webjob,当查看日志时,我看到以下错误

The webjob has no scheduled time so i manually ran the webjob from azure portal and when viewed log i see below error

[2017年1月3日06:48:38> 7e6d88:SYS INFO]状态已更改为正在初始化 [01/03/2017 06:48:38> 7e6d88:SYS INFO]检测到作业目录更改:作业文件'ICICIEmailParser.application'的时间戳在源目录和工作目录之间有所不同. [01/03/2017 06:48:39> 7e6d88:SYS INFO]使用脚本宿主-"WindowsScriptHost"运行脚本"ICICIEmailParser.exe" [01/03/2017 06:48:39> 7e6d88:SYS INFO]状态已更改为正在运行" [01/03/2017 06:48:40> 7e6d88:错误] [01/03/2017 06:48:40> 7e6d88:ERR]未处理的异常:System.AggregateException:发生一个或多个错误. ---> System.AggregateException:发生一个或多个错误. ---> System.Net.HttpListenerException:访问被拒绝 [01/03/2017 06:48:40> 7e6d88:ERR]在System.Net.HttpListener.SetupV2Config() [01/03/2017 06:48:40> 7e6d88:ERR]在System.Net.HttpListener.Start() [01/03/2017 06:48:40> 7e6d88:ERR]在Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.d__6.MoveNext() [01/03/2017 06:48:40> 7e6d88:ERR]-从上一个引发异常的位置开始的堆栈跟踪结束- [01/03/2017 06:48:40> 7e6d88:ERR]在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) [01/03/2017 06:48:40> 7e6d88:ERR]在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) [01/03/2017 06:48:40> 7e6d88:ERR]在Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.d__8.MoveNext() [01/03/2017 06:48:40> 7e6d88:ERR]-从上一个引发异常的位置开始的堆栈跟踪结束- [01/03/2017 06:48:40> 7e6d88:ERR]在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) [01/03/2017 06:48:40> 7e6d88:ERR]在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) [01/03/2017 06:48:40> 7e6d88:ERR]在Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__4.MoveNext() [01/03/2017 06:48:40> 7e6d88:ERR]-从上一个引发异常的位置开始的堆栈跟踪结束- [01/03/2017 06:48:40> 7e6d88:ERR]在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) [01/03/2017 06:48:40> 7e6d88:ERR]在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) [01/03/2017 06:48:40> 7e6d88:ERR]在Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext() [01/03/2017 06:48:40> 7e6d88:ERR] ---内部异常堆栈跟踪的结尾--- [01/03/2017 06:48:40> 7e6d88:ERR]在System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) [01/03/2017 06:48:40> 7e6d88:ERR]在System.Threading.Tasks.Task 1.GetResultCore(Boolean waitCompletionNotification) [01/03/2017 06:48:40 > 7e6d88: ERR ] at System.Threading.Tasks.Task 1.get_Result() [01/03/2017 06:48:40> 7e6d88:错误]在GmailQuickstart.Program.d__3.MoveNext() [01/03/2017 06:48:40> 7e6d88:ERR] ---内部异常堆栈跟踪的结尾--- [01/03/2017 06:48:40> 7e6d88:ERR]在System.Threading.Tasks.Task.WaitAll(Task []任务,Int32毫秒超时,CancellationToken cancelToken) [QuickTime.Program.Main(String [] args)上的[01/03/2017 06:48:40> 7e6d88:ERR] [01/03/2017 06:48:40> 7e6d88:SYS INFO]状态已更改为失败" [01/03/2017 06:48:40> 7e6d88:SYS错误]由于退出代码-532462766

[01/03/2017 06:48:38 > 7e6d88: SYS INFO] Status changed to Initializing [01/03/2017 06:48:38 > 7e6d88: SYS INFO] Job directory change detected: Job file 'ICICIEmailParser.application' timestamp differs between source and working directories. [01/03/2017 06:48:39 > 7e6d88: SYS INFO] Run script 'ICICIEmailParser.exe' with script host - 'WindowsScriptHost' [01/03/2017 06:48:39 > 7e6d88: SYS INFO] Status changed to Running [01/03/2017 06:48:40 > 7e6d88: ERR ] [01/03/2017 06:48:40 > 7e6d88: ERR ] Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.Net.HttpListenerException: Access is denied [01/03/2017 06:48:40 > 7e6d88: ERR ] at System.Net.HttpListener.SetupV2Config() [01/03/2017 06:48:40 > 7e6d88: ERR ] at System.Net.HttpListener.Start() [01/03/2017 06:48:40 > 7e6d88: ERR ] at Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.d__6.MoveNext() [01/03/2017 06:48:40 > 7e6d88: ERR ] --- End of stack trace from previous location where exception was thrown --- [01/03/2017 06:48:40 > 7e6d88: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [01/03/2017 06:48:40 > 7e6d88: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [01/03/2017 06:48:40 > 7e6d88: ERR ] at Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.d__8.MoveNext() [01/03/2017 06:48:40 > 7e6d88: ERR ] --- End of stack trace from previous location where exception was thrown --- [01/03/2017 06:48:40 > 7e6d88: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [01/03/2017 06:48:40 > 7e6d88: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [01/03/2017 06:48:40 > 7e6d88: ERR ] at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__4.MoveNext() [01/03/2017 06:48:40 > 7e6d88: ERR ] --- End of stack trace from previous location where exception was thrown --- [01/03/2017 06:48:40 > 7e6d88: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [01/03/2017 06:48:40 > 7e6d88: ERR ] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [01/03/2017 06:48:40 > 7e6d88: ERR ] at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext() [01/03/2017 06:48:40 > 7e6d88: ERR ] --- End of inner exception stack trace --- [01/03/2017 06:48:40 > 7e6d88: ERR ] at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) [01/03/2017 06:48:40 > 7e6d88: ERR ] at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) [01/03/2017 06:48:40 > 7e6d88: ERR ] at System.Threading.Tasks.Task1.get_Result() [01/03/2017 06:48:40 > 7e6d88: ERR ] at GmailQuickstart.Program.d__3.MoveNext() [01/03/2017 06:48:40 > 7e6d88: ERR ] --- End of inner exception stack trace --- [01/03/2017 06:48:40 > 7e6d88: ERR ] at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken) [01/03/2017 06:48:40 > 7e6d88: ERR ] at GmailQuickstart.Program.Main(String[] args) [01/03/2017 06:48:40 > 7e6d88: SYS INFO] Status changed to Failed [01/03/2017 06:48:40 > 7e6d88: SYS ERR ] Job failed due to exit code -532462766

我所做的事情:

我有一个Google oauth的client-secret.json文件. 我在Azure Web应用程序身份验证/授权中添加了Google机密和客户端ID 我在Google Developer Console中设置了JavaScript来源并重定向了uri

I have a client-secret.json file of google oauth. I have added google secret and client id in my azure web app authentication/authorization I set javascript origin and redirect uri in google developer console

这是我的主要方法:

static void Main(string[] args)
    {

        Task.WaitAll(GetEmail());


    }
static async Task GetEmail() {
//my c# code to read gmail inbox...

}

任何帮助将不胜感激!

预先感谢

推荐答案

未处理的异常:System.AggregateException:发生一个或多个错误. ---> System.Net.HttpListenerException:访问被拒绝

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.Net.HttpListenerException: Access is denied

根据您的描述,我假设您已遵循 .NET快速入门创建您的.NET控制台应用程序,该应用程序向Gmail API发出请求.我按照上面的教程进行了操作,并将其部署为Azure WebJobs,然后可以重现此错误.在Azure上运行命令行应用程序(WebJob)时,它将提示您授权访问并在Web服务器的默认浏览器中打开新的窗口或选项卡.但是,Azure WebJobs作为后台任务在Azure托管的网站后面进行常规工作和批处理工作,最终用户无法与WebJob交互以完成授权.

According to your description, I assumed that you have followed .NET Quickstart to create your .NET console application that makes requests to the Gmail API. I followed the above tutorial and deployed it as Azure WebJobs, then I could reproduce this error. When running your command-line application (WebJob) on Azure, it would prompt you to authorize access and open a new window or tab in the default browser of the web server. However Azure WebJobs work as a background task under behind the website hosted on Azure for doing regular jobs and batch work, the end-users couldn't Interact with your WebJob to finish the authorization.

但是我的webjobs似乎没有运行,并且当我选择发布为天蓝色的webjobs"时,没有选择安排webjob的选项.

But my webjobs doesn't seem to run and there is no option to schedule a webjob when i select publish as azure webjobs.

我知道,您可以利用以下方法来安排WebJob:

As I known, you could leverage the following approaches to schedule your WebJob:

使用 Azure Scheduler作业触发您的WebJob有一些时间表

Use Azure Scheduler job to trigger your WebJob with some schedule

使用 cron表达式安排Azure WebJobs

Schedule Azure WebJobs with cron expressions

我已经在我的azure Web应用程序身份验证/授权中添加了Google机密和客户端ID,我在Java开发人员控制台中设置了JavaScript来源并重定向了uri

I have added google secret and client id in my azure web app authentication/authorization I set javascript origin and redirect uri in google developer console

根据我的理解,您正在尝试使用Google帐户对Web应用程序进行身份验证/授权,并安排WebJob使用已记录的UserCredential读取来自Gmail的邮件.据我所知,WebJobs无法直接与您的Web应用程序通信,我假设您需要存储记录的UserCredential并安排您的Web作业来检索UserCredential以便从Gmail API读取邮件.

Per my understanding, you are trying to authenticate/authorize your web app with Google Account and schedule the WebJob to read messages from Gmail with the logged UserCredential. As I known, WebJobs couldn't directly communicate with your web app, I assumed that you need to store the logged UserCredential and schedule your webjob to retrieve the UserCredential to read messages from Gmail API.

这篇关于Azure webjobs失败[访问被拒绝]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆