首页 > 解决方案 > Azure Functions 禁止访问 API

问题描述

这是我在 Azure 门户中创建的 Azure 函数的代码:

#r "D:\home\site\wwwroot\TimerTriggerCSharp1\bin\MobileWebAPI.dll"
using System.Net;
using MobileWebAPI.Controllers;

public static void Run(TimerInfo myTimer, TraceWriter log)
{
    PayslipListController.NotifyUsersWithNewPayroll();
}

错误:

调用的目标已引发异常。系统:无法连接到远程服务器。系统:试图以一种被其对 IP 主机的访问权限所禁止的方式访问套接字。

该方法NotifyUsersWithNewPayroll正在调用一个POST API.

标签: azureazure-functions

解决方案


已经解决问题了。请参阅下面的代码。

#r "D:\home\site\wwwroot\TimerTriggerCSharp1\bin\MobileWebAPI.dll"
using System.Net;
using MobileWebAPI.Controllers;

public static void Run(TimerInfo myTimer, TraceWriter log)
{
    PayslipListController.NotifyUsersWithNewPayroll();
    //log.Info($"C# Timer trigger function executed at: {DateTime.Now}");


}

推荐阅读