現在、専用サーバーのサイトを実行していますが、将来的には Microsoft Azure クラウド プラットフォームを使用してスケールアップしたいと考えていますが、コードの特定の部分が Azure で動作するかどうかはわかりません。
このサイトは、各アイテムの画像を含むアイテムのギャラリーで構成されています。画像は sqlserver データベースに保存されます。
画像をディスクにキャッシュし、リクエストを画像にリダイレクトする http ハンドラーを作成しました (投稿の最後に示されているように)。
画像は、ASP.NET アプリケーション内の「imagecache」という仮想ディレクトリに保存されます。(つまり ~/imagecache/ )。
Web アプリは Azure プラットフォーム上の多くの仮想マシン インスタンスで実行されるため、インスタンス間でイメージを共有する必要がありますよね?
だから私の質問は本当に..私がすでに持っているものを実現する最良の方法は何ですか?
ありがとう
画像生成コード..
public class getimage : IHttpHandler {
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public void ProcessRequest (HttpContext context) {
try
{
string uniqueid = "";
if(context.Request.QueryString["id"]) uniqueid = context.Request.QueryString["id"].ToString();
string dir = "~/imagecache/";
string image_target_path = dir + "image-file-" + uniqueid + ".png";
byte[] data = null;
context.Response.ContentType = "image/png";
if (!System.IO.File.Exists(context.Server.MapPath(image_target_path)))
{
if (context.Request.QueryString["id"] != null)
{
// get image data from the database
data = ImageHelper.getDatabaseImageDataByID(Convert.ToInt32(uniqueid));
using (System.Drawing.Image img = System.Drawing.Image.FromStream(new System.IO.MemoryStream(data)))
{
// save image to disk in the virtual dir
img.Save(context.Server.MapPath(image_target_path));
}
}
else
{
// set a sample image if no id is set
image_target_path = "~/images/noimage.png";
}
}
// redirect request to image file
context.Response.Redirect(image_target_path, false);
}
catch (Exception ex)
{
log.Error(ex.Message, ex);
}
}
public bool IsReusable {
get {
return false;
}
}
}