3

私のアプリケーションでは、ドキュメントをAzureBLOBストレージにアップロードしようとしています。コードは次のとおりです。

// Namespaces for Azure
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;

public ActionResult GetPdf(HttpPostedFileBase document)
{
    int pdfocument = Request.ContentLength;

    var doctype=Request.ContentType;

    byte[] pdf = new byte[pdfocument];               
    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("Setting1"));
    CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();           
    CloudBlobContainer container = blobClient.GetContainerReference("containername");
    container.CreateIfNotExists();
    var permissions = container.GetPermissions();
    permissions.PublicAccess = BlobContainerPublicAccessType.Blob;
    container.SetPermissions(permissions);
    string uniqueBlobName = "blobname";
    CloudBlockBlob blob = container.GetBlockBlobReference(uniqueBlobName);
    blob.Properties.ContentType = doctype;
    blob.UploadByteArray(pdf);
}

アプリケーションをビルドすると、でエラーが発生しcontainer.CreateIfNotExists()ます。エラーは次のとおりです。

「Microsoft.WindowsAzure.StorageClient.CloudBlobContainer」には「CreateIfNotExists」の定義が含まれておらず、「Microsoft.WindowsAzure.StorageClient.CloudBlobContainer」タイプの最初の引数を受け入れる拡張メソッド「CreateIfNotExists」が見つかりませんでした(usingディレクティブがありませんか?またはアセンブリ参照?)'。

そのエラーに対してどの名前空間を追加できますか?

4

1 に答える 1

7

CreateIfNotExistsは、Azureライブラリのバージョン2.0の一部です。

バージョン1.7のStorageClient名前空間を使用している場合は、CreateIfNotExistを呼び出す必要があります(複数形ではありません)

于 2013-02-18T10:50:38.697 に答える