0

ロール環境にファイルをローカルに保存するクラウド サービスとして Azure でホストされている MVC Web アプリケーションがあります。これは、サービスを 2 つのインスタンスで高可用性に移行するまで実行可能なソリューションでしたが、現在はファイルがアップロードされた環境にのみ書き込まれるため、ユーザーがロード バランサーのために他のインスタンスにジャンプすると、これらのファイルは使用できなくなります。

インスタンス [0] にログインしている場合、インスタンス [1] の他のロール環境に書き込む手段はありますか。セッションは、Redis キャッシュを使用して両方のインスタンスに保存されます。現在、ロール環境に書き込む私のコードは次のとおりです。

public static string ImportContentPackage(string iEnVar, string fileName, HttpPostedFileBase zipFile, string companyName)
{
  //Get the Local Storage place.
  LocalResource tempDirectory = RoleEnvironment.GetLocalResource("TempZipDirectory");

  //Now System.IO to store the Zip file in there. Get the file name without the extension.
  string actualFileName = fileName.Split('.')[0];

  System.IO.Directory.CreateDirectory(tempDirectory.RootPath + "\\" + companyName + "\\" + actualFileName); 

  string holderDir = tempDirectory.RootPath + @"\" + companyName + @"\" + actualFileName;

  try
  {
    //Clear out any directories that might be there.
    CleanImportDirectory(holderDir);

    //Save the zip into the package to enable unzipping.
    BinaryReader br = new BinaryReader(zipFile.InputStream);
    File.WriteAllBytes(tempDirectory.RootPath + "\\" + fileName, br.ReadBytes(zipFile.ContentLength));


    // Unzip the content package into a local directory for processing
    SCORM.Validation.Handlers.UnZipFile uzh = new SCORM.Validation.Handlers.UnZipFile(tempDirectory.RootPath + "\\" + fileName, holderDir);

    SCORM.Validation.Helpers.Result result = uzh.Extract();

    if(result.PackageCheckerMessages.Count > 0)
    {
      holderDir = "";
    }
  }
  catch (System.NullReferenceException npe)
  {
  }
  return holderDir;
}

LocalResource tempDirecory 変数は、どちらも TempZipDirectory という名前であるため、両方のインスタンスで同じである必要があります。

4

1 に答える 1

-1

Azure Files で可能になりました。http://fabriccontroller.net/blog/posts/using-the-azure-file-service-in-your-cloud-services-web-roles-and-worker-role/

于 2014-07-23T09:22:31.423 に答える