0

クラス ライブラリに Web 参照 (WSDL) を追加し、タイマーでトリガーされる C# Azure 関数( Azure 関数の詳細を参照) でその dll を参照しました。クラス ライブラリには、Web サービス (Web サービス ラッパーの一種) からメソッドを呼び出すクラス EmployeeService があります。コンソール アプリケーションからクラス lib メソッド (GetEmployees) を呼び出すと、Web サービスに対して認証され、結果が返されますが、同じコードと資格情報に対して azure 関数を実行すると、401 が返されます。ここで何が間違っているのかわかりません。

#r "MyConsult.Service.dll"
#r "Newtonsoft.Json.dll"

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using Newtonsoft.Json;
using System.Net;
using MyConsult.Service.Service;

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

    try
    {
         EmployeeService _empService = new EmployeeService();                  
         var emps = _empService.GetEmployees();

         int count = emps.Where(x => !string.IsNullOrEmpty(x.Email)).Select(x => x.Email).Distinct().Count();
         log.Info($"employee count : {count}");       
     }
     catch (Exception ex)
     {
         log.Info($"Exception Message: {ex.Message}");
         log.Info($"Exception Stack Trace: { ex.StackTrace}");
     }
}
4

1 に答える 1

0

コンソール アプリケーションは、app.config のサービス構成設定に基づいて認証されている可能性があります。関数では、クライアント/プロキシを構築するときに、これらの設定をプログラムで適用する必要があります。

于 2016-05-12T14:40:27.130 に答える