2017-03-29 8 views
0

Microsoft Azure関数内でMicrosoft.Azure.SqlDatabase.ElasticScale.Clientパッケージを使用します。Azure関数内でElastic Sc​​aleパッケージを使用します。

次のように私はproject.jsonを追加しました:

{ 
    "frameworks": { 
    "net452":{ 
     "dependencies": { 
     "Microsoft.Azure.SqlDatabase.ElasticScale.Client": "1.3.3" 
     } 
    } 
    } 
} 

は機能:

#r "System.Data" 
#r "Newtonsoft.Json" 

using System.Net; 
using Newtonsoft.Json; 
using System.Data.SqlClient; 
using Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement; 

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) 
{ 
    ShardMapManager shardMapManager; 
    return req.CreateResponse(HttpStatusCode.OK); 
} 

私は次のエラーを取得:

error CS0234: The type or namespace name 'SqlDatabase' does not exist in the namespace 'Microsoft.Azure' (are you missing an assembly reference?) 
error CS0246: The type or namespace name 'ShardMapManager' could not be found (are you missing a using directive or an assembly reference?) 

答えて

1

あなたは#Rが欠落していますステートメントへのreference external assembly

#r "Microsoft.Azure.SqlDatabase.ElasticScale.Client.dll"または

#r "bin\Microsoft.Azure.SqlDatabase.ElasticScale.Client.dll"

を(私はいつものパスに問題がありました):Microsoft.Azure.SqlDatabase.ElasticScale.Clientパッケージが試みるので、その後、Microsoft.Azure.SqlDatabase.ElasticScale.Client.dllをインストールします。

CSXスクリプトを使用せず、代わりにhereというテクニックを使用してプリコンパイルされたバイナリを使用することをお勧めします。次に、C#の利点を最大限活用し、アセンブリを含めるには#rステートメントを追加する必要はありません。

+0

これはgretaのヘルプです。 "reference external assembly"リンクは答えました:私はproject.json内でnet452をnet46に変更する必要がありました。その後、正常に動作しました。アセンブリを明示的に参照する必要はありませんでした。コンパイルされたバイナリのリンクをありがとう、それははるかに良い長期計画に見えます。 – SpecWin

+0

プリコンパイルされたバイナリに変換され、うまくいきます。再度、感謝します – SpecWin

関連する問題