代码之家  ›  专栏  ›  技术社区  ›  Node.JS

azure sdk for net在Mac上引发异常

  •  4
  • Node.JS  · 技术社区  · 7 年前

    basically this nuget package ). 我正在使用Mac。

    值“Darwin17.7.0DarwinKernelVersion17.7.0WedOct10230614PDT2018rootxnu-4570.71.131/RELEASE_X86_64”的格式无效。

    var serviceClientCredentials = new AzureApiKeyServiceClientCredentials("<key>");
    // Throw an exception here
    var client = new TextAnalyticsClient(_serviceClientCredentials);
    

    ServiceClientCredentials类:

    public class AzureApiKeyServiceClientCredentials : ServiceClientCredentials
    {
        private readonly string _subscriptionKey;
    
        public AzureApiKeyServiceClientCredentials(string subscriptionKey)
        {
            _subscriptionKey = subscriptionKey;
        }
    
        public override Task ProcessHttpRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            request.Headers.Add("Ocp-Apim-Subscription-Key", _subscriptionKey);
    
            return base.ProcessHttpRequestAsync(request, cancellationToken);
        }
    }
    

    :

    TextAnalyticsClient Darwin..../RELEASE_X86_64 ). 更具体地说,我在源代码中看到,它是设置 OsVersion HttpClient 而且它不是url友好的值和

    this.UpdateDefaultUserAgentList("OSVersion", this.OsVersion);
    

    我创建了一个 issue on GitHub . 所以,他们所需要做的就是 always call CleanUserAgentInfoEntry(_osVersion)

    我从他们的消息来源中看到他们得到了 带我飞 new PlatformInfo(); 我想知道有没有可能改变 RuntimeInformation.OSDescription

    我创造了一个 pull request

    1 回复  |  直到 7 年前
        1
  •  0
  •   Node.JS    7 年前

    我刚刚解决了这个问题, thanks to @shahabhijeet . 我安装了最新版本的 Microsoft.Rest.ClientRuntime 它解决了这个问题。

    https://github.com/Azure/azure-sdk-for-net/issues/5046