1

在我的 Azure 函数中,我引用了Microsoft.WindowsAzure.Management.WebSites程序集

{
  "frameworks": {
    "net46":{
      "dependencies": {
        "Microsoft.WindowsAzure.Management.WebSites": "4.0.0"
      }
    }
   }
}

并尝试使用WebSiteManagementClient

var client = new WebSiteManagementClient(
    new Microsoft.WindowsAzure.CertificateCloudCredentials("my sub ID", cert));

但它失败并出现错误:

Microsoft.WindowsAzure.Common: 
The type initializer for 'Microsoft.WindowsAzure.Common.ServiceClient`1'
threw an exception. Microsoft.WindowsAzure.Common: Operation is not 
supported on this platform.

在日志中我可以看到

Unable to find assembly 'Microsoft.WindowsAzure.Common.NetFramework'. Are you missing a private assembly file?
Unable to find assembly 'Microsoft.WindowsAzure.Common.WindowsStore'. Are you missing a private assembly file?
Unable to find assembly 'Microsoft.WindowsAzure.Common.WindowsPhone'. Are you missing a private assembly file?
Unable to find assembly 'Microsoft.WindowsAzure.Common.WindowsPhone81'. Are you missing a private assembly file?
Unable to find assembly 'Microsoft.WindowsAzure.Common.Silverlight'. Are you missing a private assembly file?
Unable to find assembly 'Microsoft.WindowsAzure.Common.Test'. Are you missing a private assembly file?

我也尝试引用所有相关的 NuGet 包,但没有修复错误。

我错过了什么?

4

1 回答 1

0

添加以下项目解决了该问题。

 //Add in run.csx
 using Microsoft.WindowsAzure.Management.WebSites; 

在 project.json 中添加下面的 JSON 配置

    {
      "frameworks": {
        "net46":{
         "dependencies": {
         "Microsoft.WindowsAzure.Management.WebSites": "4.0.0",
         "Microsoft.WindowsAzure.Common": "1.4.1"
         }
        }
       }
      }

有关其他信息:我也尝试过使用最新的预发布版本,

    "Microsoft.WindowsAzure.Management.WebSites": "5.0.0-prerelease"

Azure Functions 也与预发布版配合得很好。

于 2017-03-01T14:51:26.187 回答