2017-10-08 23 views
1

我創建了一個Azure函數來連接到CosmosDB圖。我正在使用nuget軟件包Microsoft.Azure.Graph 0.3.0-preview,並且在我點擊函數的端點時出現錯誤。無法加載文件或程序集'Microsoft.Azure.Graphs'

Exception while executing function: GetTrain -> Could not load file or assembly 'Microsoft.Azure.Graphs, Version=0.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

該函數的代碼如下,但它甚至沒有得到儘可能這一點。

[FunctionName("GetThing")] 
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", Route = "thing/{id}")]HttpRequestMessage req, string id, TraceWriter log) 
{ 
    log.Info("C# HTTP trigger function processed a request."); 

    string endpoint = ConfigurationManager.AppSettings["endpoint"]; 
    string authKey = ConfigurationManager.AppSettings["authkey"]; 
    string db = ConfigurationManager.AppSettings["db"]; 
    string collection = ConfigurationManager.AppSettings["collection"]; 

    DocumentClient client = new DocumentClient(new Uri(endpoint), authKey, 
     new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp }); 

    DocumentCollection graph = await client.CreateDocumentCollectionIfNotExistsAsync(
      UriFactory.CreateDatabaseUri(db), 
      new DocumentCollection { Id = collection }, 
      new RequestOptions { OfferThroughput = 1000 }); 


     IDocumentQuery<dynamic> query = client.CreateGremlinQuery<dynamic>(graph, $"g.V('{id}').has('thing')"); 

    // Fetching the name from the path parameter in the request URL 
    return req.CreateResponse(HttpStatusCode.OK, "Hello"); 
} 

更新

似乎還有生成警告,完全沒有看到。有什麼想法嗎?

警告MSB3270有該項目正在建造「MSIL」的處理器體系結構和的參考「C的處理器體系結構之間的失配:\用戶\ blah.nuget \包\ microsoft.azure.graphs \ 0.3 .0-preview \ lib \ net461 \ Microsoft.Azure.Graphs.dll「,」AMD64「。這種不匹配可能會導致運行時失敗。請考慮通過Configuration Manager更改項目的目標處理器體系結構,以便在項目和引用之間調整處理器體系結構,或者使用與項目的目標處理器體系結構相匹配的處理器體系結構來依賴引用。

+0

我也可以在我身邊複製它,我們可以將我們的[feedback](https://github.com/Azure/Azure-Functions/issues)給予azure函數團隊 –

+0

您是否有任何編譯時警告? –

+0

是的,更新了警告 –

回答

2

對於包Microsoft.Azure.Graphs> = 0.3.1-preview,此問題已解決。

正如其他人指出的那樣,問題是Microsoft.Azure.Graphs以前只針對x64平臺。彙編的新版本現在編譯爲AnyCPU(MSIL)。

相關問題