ãµã€ã¯ã«ã®æåã®5ã€ã®éšåã¯ã ããããå ¥æã§ããŸã ã ã·ãªãŒãºã®ãã®ããŒãã§ã¯ãWindows AzureããŒã«ã¢ãã«ãWindows AzureãµãŒãã¹ãã¹ãããã³ã¹ãã¬ãŒãžãµãŒãã¹ã䜿çšããåçŽãªã¢ããªã±ãŒã·ã§ã³ã䜿çšããŠãåçŽãªWebãµã€ããã¯ã©ãŠããµãŒãã¹ïŒä»¥åã®ãã¹ããµãŒãã¹ïŒã«ç§»è¡ããããšãæ€èšããŸãã
次ã®ã·ããªãªãèŠãŠã¿ãŸãããïŒWindows Azure Webãµã€ãã«æ¢ã«Webãµã€ãïŒããšãã°ãåŸã§èª¬æããæšæºASP.NET MVC 4 Webãµã€ãïŒãå±éããŸãããããã°ãããããšWebãµã€ãã«è¿œå ã®æ©èœ-ãŠãŒã¶ãŒãããªãã®ãŠã§ããµã€ãã«è¡ããèªåã®ã®ã£ã©ãªãŒã«ç»åãã¢ããããŒãã§ããããšãå¿ èŠã§ãã 1ã€ã®Webãµã€ãæ©èœã䜿çšããŠãã®ãããªã·ããªãªãå®è£ ããŸãããèŠä»¶ã®ãªã¹ãã«ã¯ãWebãµã€ãã®æè»ãªã¹ã±ãŒã©ããªãã£ã®æ¡ä»¶ãå«ãŸããŠããŸãã Windows Azure Webãµã€ãã®ã¿ã䜿çšããå ŽåãWebãµã€ãå šäœã®ã¿ãã¹ã±ãŒãªã³ã°ã§ããŸãããããã¯éå¹ççãªãœãªã¥ãŒã·ã§ã³ã§ããã»ãšãã©ã®å Žåãäž»ãªè² æ ã¯WebãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã§ã¯ãªãç»åããã»ããµã«ãããŸãã Webãµã€ããã¯ã©ãŠããµãŒãã¹ã«ç§»è¡ããWindows Azureã¯ã©ãŠããµãŒãã¹ã®åœ¹å²ã¢ãã«ã«åºã¥ããŠã¢ãŒããã¯ãã£ãåæ€èšããWindows Azure Blobã¹ãã¬ãŒãžãšãµãŒãã¹ãã¹ãã¥ãŒã䜿çšãããšããã®ã·ããªãªã®å¹æçãªå®è£ ãäœæã§ããŸãã ã·ãªãŒãºã®ãã®ããŒãã§ã¯ã2ã€ã®ã¬ã€ã€ãŒã§æ§æãããã¯ã©ãŠãã¢ããªã±ãŒã·ã§ã³ãäœæããŸãã
1ïŒWebããŒã«ãšããŠå®è£ ãããWebã€ã³ã¿ãŒãã§ã€ã¹ã ã¢ããªã±ãŒã·ã§ã³ã®ã¡ã€ã³ããŒãžã§ããŠãŒã¶ãŒã¯ç»åãã¢ããããŒãããããããŠã³ããŒãæžã¿ã®ç»åã衚瀺ãããã§ããŸãã ã€ã¡ãŒãžãèªã¿èŸŒãã åŸãWebããŒã«ã¯BLOBã¹ãã¬ãŒãžå ã®ã€ã¡ãŒãžãBLOBã³ã³ãããŒã«éä¿¡ããŸããBLOBã³ã³ãããŒã®ååã¯ã¿ã¹ã¯ãç°¡çŽ åããããã«äºåå®çŸ©ããããã®åŸãã€ã¡ãŒãžãå«ãBLOBãžã®ãªã³ã¯ã§æ§æãããã¡ãã»ãŒãžãService Busãã¥ãŒã«å ¥ããŸãã
2ïŒWorkerããŒã«ãšããŠå®è£ ãããç»åããã»ããµã ç¡éã«ãŒãã§ã¯ããã³ãã©ãŒã¯WebããŒã«ããã®ã¡ãã»ãŒãžãService Busãã¥ãŒã«ç §äŒãããã¥ãŒã«ã¡ãã»ãŒãžãããå Žåãã¡ãã»ãŒãžãååŸããã€ã¡ãŒãžBLOBãžã®ãªã³ã¯ãåä¿¡ããã³ããŒãœãŒã¹BLOBã¡ã«ããºã ã䜿çšããŠæ°ããBLOBãäœæããŸãåãã€ã¡ãŒãžãblobãªããžããªã«é 眮ããŸãã
Windows Azureã§ã¯ã©ãŠããµãŒãã¹ãæ§æãã
Webãã©ãŠã¶ãŒã§http://windows.azure.comãéããWindows Azureã¢ã«ãŠã³ãããªã³ã¯ãããŠããWindows Live IDã䜿çšããŠãã°ã€ã³ããŸãã
ã¢ããªã±ãŒã·ã§ã³ããŒã¿ãä¿åãããæ°ããã¹ãã¬ãŒãžã¢ã«ãŠã³ããäœæããŸãã Windows Azureã¡ãã¥ãŒããã[ æ°ããã¹ãã¬ãŒãžã¢ã«ãŠã³ã ]ãã¯ãªãã¯ããŸãã 衚瀺ããã[ æ°ããã¹ãã¬ãŒãžã¢ã«ãŠã³ãã®äœæ]ãã€ã¢ãã°ããã¯ã¹ã§ã[ãµãã¹ã¯ãªãã·ã§ã³ã®éžæ]ããããããŠã³ãªã¹ãã§ãµãã¹ã¯ãªãã·ã§ã³ãéžæããŸãã[ URLã®å ¥å]ããã¹ãããã¯ã¹ã«ãã¹ãã¬ãŒãžã¢ã«ãŠã³ãã®ååãå ¥åããŸãïŒäŸïŒ <yourname> gallery ãããã§<yourname>ã¯äžæã®ååïŒã Windows Azureã¯ãã®å€ã䜿çšããŠãã¹ãã¬ãŒãžã¢ã«ãŠã³ããµãŒãã¹ã®ãšã³ããªãã€ã³ãURLãäœæããŸãã [ äœæ ]ãéžæããããã¢ãã£ããã£ã°ã«ãŒããéžæããŠãããããããŠã³ãªã¹ãã§[ æ°ããã¢ãã£ããã£ã°ã«ãŒãã®äœæ ]ãã¯ãªãã¯ããŸã ã [ æ°ããã¢ãã£ããã£ã°ã«ãŒãã®äœæ ]ãã€ã¢ãã°ããã¯ã¹ã§ã[ ã¢ãã£ããã£ã°ã«ãŒãå]ããã¹ãããã¯ã¹ã«ã¢ãã£ããã£ã°ã«ãŒãåãå ¥åããããããããŠã³ãªã¹ãã§[ å Žæ]ãéžæããŠ[ OK ]ãã¯ãªãã¯ããŸãã [ æ°ããã¹ãã¬ãŒãžã¢ã«ãŠã³ãã®äœæ]ãã€ã¢ãã°ããã¯ã¹ã«æ»ãã[ äœæ ]ãã¯ãªãã¯ããŠæ°ããã¹ãã¬ãŒãžã¢ã«ãŠã³ããäœæããŸãã
ã¢ã«ãŠã³ããåæåãããããªãŒã ã¹ãã¬ãŒãžã¢ã«ãŠã³ããæŽæ°ããããã»ã¹ãŸã§åŸ ã¡ãŸã ã [ããããã£]ããããã£ããŒã«ã¯ãããŒã«ãã¢ã«ãŠã³ãã®åãµãŒãã¹ã«é¢é£ä»ããããURLã衚瀺ãããããšã«æ³šæããŠãã ããã ããŒã«ãã¢ã«ãŠã³ãã®ãããªãã¯åãèšé²ããŸãâãšã³ããªãã€ã³ãã®URLã®æåã®ã»ã°ã¡ã³ãã [ããããã£]ããããã£ããŒã®ãã©ã€ããªã¢ã¯ã»ã¹ããŒã®æšªã«ãã[衚瀺 ]ãã¿ã³ãã¯ãªãã¯ããŸãã [ã¹ãã¬ãŒãžã¢ã¯ã»ã¹ããŒã®è¡šç€º]ãã€ã¢ãã°ããã¯ã¹ã§ã[ ã¯ãªããããŒãã«ã³ããŒ ïŒ ãã©ã€ããªã¢ã¯ã»ã¹ããŒã®æšªïŒ]ãã¯ãªãã¯ããŸãã ã³ããŒãããå€ã¯ãã¢ããªã±ãŒã·ã§ã³ãæ§æããããã«å¿ èŠã«ãªããŸãã
ã¢ããªã±ãŒã·ã§ã³ã®ã³ãŒããå®è¡ããã³ã³ãã¥ãŒãã£ã³ã°ãµãŒãã¹ãäœæããŸããå·Šãã€ã³ã§ã[ ãã¹ãããããµãŒãã¹ ]ãã¯ãªãã¯ããã¡ãã¥ãŒã«ãã[ æ°ãããã¹ãããããµãŒãã¹ ]ãã¿ã³ãã¯ãªãã¯ããŸãã [ æ°ãããã¹ããããµãŒãã¹ã®äœæ ]ãã€ã¢ãã°ããã¯ã¹ã§ã[ãµãã¹ã¯ãªãã·ã§ã³ã®éžæ]ããããããŠã³ãªã¹ããããµãã¹ã¯ãªãã·ã§ã³ãéžæããŸãã [ãµãŒãã¹ã®ååãå ¥åããŠãã ãã]ããã¹ãããã¯ã¹ã«ãµãŒãã¹åãå ¥åã ãé©åãªå€ãå ¥åããŠURLãæå®ããŸããããšãã°ã <yourname> galleryãªã©ã ãµãŒãã¹ã®URLãã¬ãã£ãã¯ã¹ãå ¥åããŸã ã Windows Azureã¯ãã®å€ã䜿çšããŠããµãŒãã¹ãšã³ããªãã€ã³ãã®URLãäœæããŸãã [ ã¢ãã£ããã£ã°ã«ãŒãã®äœæãŸãã¯éžæ]ããããããŠã³ãªã¹ãã§ãããŒã«ãã¢ã«ãŠã³ãçšã«ä»¥åã«äœæããã¢ãã£ããã£ã°ã«ãŒããéžæããŸãã [ å±éããªã]ãæå®ãã [ OK]ãã¯ãªãã¯ããŠãµãŒãã¹ãäœæããåæåããã»ã¹ãå®äºãããŸã§åŸ ã¡ãŸã[ ãµãŒãã¹ãã¹ãã¢ã¯ã»ã¹å¶åŸ¡ãšãã£ãã·ã¥ ]ã¿ãã«ç§»åããŸãã [ ãµãŒãã¹ãã¹ ]ã¿ãã«ç§»åããŸãã æ°èŠãã¯ãªãã¯ããŸãã éãã[ æ°ãããµãŒãã¹ããŒã ã¹ããŒã¹ã®äœæ ]ãã€ã¢ãã°ããã¯ã¹ã§ãããŒã ã¹ããŒã¹ã® åå ïŒ mytestservicebusãªã©ïŒãå ¥åããå Žæã®é åãéžæããŠã[ ããŒã ã¹ããŒã¹ã® äœæ ]ãã¯ãªãã¯ããŸãã ã äœæãããããŒã ã¹ããŒã¹ãéžæãã[ ããã©ã«ãããŒ]ãã£ãŒã«ãã®[ ãããã㣠]ããã«ã®[衚瀺 ]ãã¿ã³ãã¯ãªãã¯ããŸãã [ ããã©ã«ãã㌠]ãã€ã¢ãã°ããã¯ã¹ããããã©ã«ãã®çºè¡è ãšããã©ã«ãããŒã®å€ãã³ããŒããŸãã
å±éããã³ã¹ãã¬ãŒãžãµãŒãã¹ãæ§æãããŸãã Service Busåå空éãäœæãããŸããã
ASP.NET MVC 4ã¢ããªã±ãŒã·ã§ã³ãæ§æãã
管çè æš©éã§Visual Studio 2012ãéããŸãã
æ°èŠãããžã§ã¯ããã¯ãªãã¯ããŸãã Web \ ASP.NET MVC 4 Webã¢ããªã±ãŒã·ã§ã³ãã³ãã¬ãŒããéžæããŸã ïŒå³1ïŒã ãããžã§ã¯ãã«MVC4Galleryãšããååãä»ããŸãã [ ã€ã³ã¿ãŒãããã¢ããªã±ãŒã·ã§ã³]ãéžæãã[ åäœãã¹ããããžã§ã¯ãã®äœæ ]ãªãã·ã§ã³ããªãã«ããŸãã OKãã¯ãªãã¯ããŸãã ãããžã§ã¯ããäœæãããã®ãåŸ ã¡ãŸãã
å³ 1. Visual Studio 2012ã®Webãããžã§ã¯ããã³ãã¬ãŒãã®ãªã¹ã
Modelsãã£ã¬ã¯ããªãå³ã¯ãªãã¯ããŸãã [ è¿œå ] => [ã¯ã©ã¹]ãã¯ãªãã¯ããŸãã éãããã€ã¢ãã°ããã¯ã¹ã§ã Imageãšå ¥åããŸãã csãã¯ãªãã¯ããŠ[ OK ]ãã¯ãªãã¯ããŸãã ç»åãã¡ã€ã«ã®å 容ã眮ãæããŸãã 以äžã®ã³ãŒããžã®CS ã
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace MVC4Gallery.Models { public class Image { public string Title{ get; set; } public string Link{ get; set; } }}
ãã¡ã€ã«Views \ Home \ IndexãéããŸãã cshtmlãéã ããã®å 容ã以äžã®ã³ãŒãã«çœ®ãæããŸãã
<header> <div class="content-wrapper"> <div class="float-left"> <p class="site-title"> - </div> </div> </header> <div id="body"> <section class="featured"> <div class="content-wrapper"> <form action="/Home/Upload" method="post" enctype="multipart/form-data"> <label for="title"> <label for="FileData"> </label> <input type="file" id="FileData" name="FileData" /><br /> <input type="submit" value="" /> </form> "": @foreach (var image in ViewData.Model) { @image.Title <br /> <img width="100" height="100" src="@image.Link" /><br /> } </div> </section> </div>
Controllers \ HomeControllerãã¡ã€ã«ãéããŸãã csãå®è¡ãããã®å 容ã次ã®ã³ãŒãã«çœ®ãæããŸãã å¿ èŠãªäŸåé¢ä¿ãšã©ã€ãã©ãªã¯æ¬¡ã®æ®µèœã§è¿œå ãããŸãã
using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Web; using System.Web.Mvc; using Microsoft.ServiceBus.Messaging; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.StorageClient; using MVC4Gallery.Models; namespace MvcApplication1.Controllers { public class HomeController : Controller { public ActionResult Index() { List<Image> images = getBlobs("ourgallery"); return View(images); } [HttpPost] [ActionName("Upload")] public ActionResult Upload(string author, string title) { this.SendBlobToStorage(author); return RedirectToAction("Index"); } public void SendBlobToStorage(string author) { try { HttpPostedFileBase file = Request.Files[0]; CloudBlob blob = getBlobContainer("ourgallery").GetBlobReference(file.FileName); NameValueCollection metadata = new NameValueCollection(); metadata["title"] = file.FileName; blob.UploadFromStream(file.InputStream); BrokeredMessage msg = new BrokeredMessage(blob.Uri.AbsoluteUri); SendBrokeredMessageToServiceBusQueue(msg); } catch (StorageClientException e) { Console.WriteLine(" : " + e.Message); System.Environment.Exit(1); }} public List<Image> getBlobs(string author){ CloudBlobContainer container = getBlobContainer(author); List<Image> images = new List<Image>(); foreach (CloudBlob blob in container.ListBlobs()) { blob.FetchAttributes(); Image image = new Image(); image.Link = blob.Uri.AbsoluteUri; image.Title = blob.Metadata["title"]; images.Add(image); } return images; } public static CloudBlobContainer getBlobContainer(string userId) { var account = CloudStorageAccount.FromConfigurationSetting("storageaccount"); CloudBlobContainer container = account.CreateCloudBlobClient().GetContainerReference(userId); container.CreateIfNotExist(); var permissions = container.GetPermissions(); permissions.PublicAccess = BlobContainerPublicAccessType.Container; container.SetPermissions(permissions); return container; } public static void SendBrokeredMessageToServiceBusQueue(BrokeredMessage msg) { QueueDescription qd = new QueueDescription("servicebustest"); qd.MaxSizeInMegabytes = 5120; qd.DefaultMessageTimeToLive = new TimeSpan(0, 1, 0); string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString"); QueueClient Client = QueueClient.CreateFromConnectionString(connectionString, "servicebustest"); Client.Send(msg); }}}
Referencesãã£ã¬ã¯ããªãå³ã¯ãªãã¯ããŸãã [ åç §ã®è¿œå ]ãéžæããŸãã éãããã€ã¢ãã°ããã¯ã¹ïŒå³3ïŒã§ã次ã®ã¢ã»ã³ããªãéžæããŸãã
Microsoft.WindowsAzure.StorageClient 1.7.0.0
Microsoft.WindowsAzure.Configuration 1.7.0.0
Microsoft.WindowsAzure.ServiceRuntime 1.7.0.0
Microsoft.ServiceBus 1.7.0.0
System.Runtime.Serialization 4.0.0.0
å³ 3.ãããžã§ã¯ãã®ã¢ã»ã³ããªã®éžæã
ã°ããŒãã«ãã¡ã€ã«ãéããŸãã asaxãå®è¡ã ã以äžã®ã³ãŒããApplication _ StââartïŒïŒã¡ãœããã«è¿œå ããŸãã
CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSettingPublisher) => { var connectionString = RoleEnvironment.GetConfigurationSettingValue(configName); configSettingPublisher(connectionString); });
ãããžã§ã¯ããå³ã¯ãªãã¯ããŸãã [ Windows Azureã¯ã©ãŠããµãŒãã¹ãããžã§ã¯ãã®è¿œå ]ãéžæããŸã ïŒå³4ïŒã
å³ 4.ã¯ã©ãŠããããžã§ã¯ãããœãªã¥ãŒã·ã§ã³ã«è¿œå ãã
äœæãããMVC 4ã®ã£ã©ãªãŒãããžã§ã¯ãã®[ ããŒã« ]ãå³ã¯ãªãã¯ããŸãã 玺Azure è¿œå ãéžæããŸãã [ æ°ããã¯ãŒã«ãŒããŒã«ãããžã§ã¯ã]ãã¯ãªãã¯ããŸãïŒå³5ïŒã
å³ 5. WorkerããŒã«ã®ãããžã§ã¯ãããœãªã¥ãŒã·ã§ã³ã«è¿œå ãã
Windows Azure Tools 1.7ã§ã¯ã Service Busã䜿çšããããã«æ¢ã«æ§æãããŠããæ°ããWorkerããŒã«ãã³ãã¬ãŒããæ¢ã«è¿œå ãããŠããŸãã [ æ°ããããŒã«ãããžã§ã¯ãã®è¿œå ]ãŠã£ã³ããŠã§ã[ ãµãŒãã¹ãã¹ãã¥ãŒãæã€ã¯ãŒã«ãŒããŒã« ] ãéžæããŠ[ è¿œå ] ãã¯ãªãã¯ããŸãïŒå³6ïŒã
å³ 6. Service Busãã¥ãŒã䜿çšããããã«æ§æãããã¯ãŒã«ãŒããŒã«ãããžã§ã¯ãã®è¿œå
WorkerRole.csãã¡ã€ã«ãéãããã®å 容ã以äžã®ã³ãŒãã«çœ®ãæããŸãã
using System; using System.Collections.Specialized; using System.Diagnostics; using System.Net; using System.Threading; using Microsoft.ServiceBus; using Microsoft.ServiceBus.Messaging; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.ServiceRuntime; using Microsoft.WindowsAzure.StorageClient; namespace WorkerRoleWithSBQueue1 { public class WorkerRole : RoleEntryPoint { // The name of your queue const string QueueName = "servicebustest"; // QueueClient is thread-safe. Recommended that you cache // rather than recreating it on every request QueueClient Client; bool IsStopped; public override void Run() { while (!IsStopped) { try { // BrokeredMessage receivedMessage = null; receivedMessage = Client.Receive(); if (receivedMessage != null) { // . , , . GetBlobFromStorage("ourgallery", receivedMessage.GetBody<string>()); receivedMessage.Complete(); }} catch (MessagingException e) { if (!e.IsTransient) { Trace.WriteLine(e.Message); throw; } Thread.Sleep(10000); } catch (OperationCanceledException e) { if (!IsStopped) { Trace.WriteLine(e.Message); throw; }}}} public override bool OnStart() { CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSettingPublisher) => { var connectionString = RoleEnvironment.GetConfigurationSettingValue(configName); configSettingPublisher(connectionString); }); // ServicePointManager.DefaultConnectionLimit = 12; // , string sbconnectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString"); var namespaceManager = NamespaceManager.CreateFromConnectionString(sbconnectionString); if (!namespaceManager.QueueExists(QueueName)) { namespaceManager.CreateQueue(QueueName); } // Service Bus Client = QueueClient.CreateFromConnectionString(sbconnectionString, QueueName); IsStopped = false; return base.OnStart(); } public override void OnStop() { // Service Bus IsStopped = true; Client.Close(); base.OnStop(); } public void GetBlobFromStorage(string author, string title) { try { CloudBlob sourceBlob = getBlobContainer("ourgallery").GetBlobReference(title); CloudBlob newBlob = getBlobContainer("ourgallery").GetBlobReference(title + "small_copy"); newBlob.CopyFromBlob(sourceBlob); NameValueCollection metadata = new NameValueCollection(); metadata["title"] = title + "small_copy"; } catch (StorageClientException e) { Console.WriteLine(" : " + e.Message); System.Environment.Exit(1); }} public static CloudBlobContainer getBlobContainer(string userId) { var account = CloudStorageAccount.FromConfigurationSetting("storageaccount"); CloudBlobContainer container = account.CreateCloudBlobClient().GetContainerReference(userId); container.CreateIfNotExist(); return container; }}}
WebRole.csãã¡ã€ã«ãMVC4Galleryãããžã§ã¯ãã«è¿œå ãããã®ã³ã³ãã³ãã以äžã®ã³ãŒãã§çœ®ãæããŸãã
using System; using System.Collections.Generic; using System.Linq; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.Diagnostics; using Microsoft.WindowsAzure.ServiceRuntime; using Microsoft.WindowsAzure.StorageClient; namespace MVC4Gallery { public class WebRole : RoleEntryPoint { public override bool OnStart() { RoleEnvironment.Changing += RoleEnvironmentChanging; return base.OnStart(); } private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e) { if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange)) { e.Cancel = true; }}}}
Rolesã¯ã©ãŠããããžã§ã¯ãã®MVC 4ã®ã£ã©ãªãŒã§ããŠã¹ã®å³ãã¿ã³ãããã«ã¯ãªãã¯ããŠãWebããŒã«ã管çããããã®GUIãéããŸãïŒå³7ïŒã
å³ 7. WebããŒã«ç®¡çã®ã°ã©ãã£ã«ã«ã€ã³ã¿ãŒãã§ã€ã¹
[ æ§æ ]ã¿ãã§ã[ 蚺æãæå¹ã«ãã ]ãªãã·ã§ã³ããªãã«ããŸãã [èšå® ]ã¿ãã«ç§»åãã [èšå®ã® è¿œå ]ãã¯ãªãã¯ããŠã storageaccountãšããæ°ããæ§æèšå®ãäœæããŸãã ãã®ã¿ã€ããæ¥ç¶æååãšããŠæå®ããçç¥èšå·ãã¿ã³ãã¯ãªãã¯ããŠæ¥ç¶æååãèšå®ããŸãã å¿ èŠãªããŒã¿ã¯ããŒã1ã§èšé²ãããŸããã [ èšå®ã®è¿œå ]ãã¯ãªãã¯ãã Microsoft.ServiceBus.ConnectionStringãšããååïŒã¿ã€ãã¯StringïŒãå ¥åãã[ å€]ãã£ãŒã«ãã«æ¬¡ã®è¡ãæ¿å ¥ããŸãã
ãšã³ããã€ã³ã= sbïŒ// [åå空é] .servicebus.windows.net; SharedSecretIssuer = owner; SharedSecretValue = [DefaultKey]
Endpointéšåã®åå空éåã SharedSecretIssuerã® ããã©ã«ãçºè¡è ãããã³SharedSecretValueã® ããã©ã«ãããŒã¯ã©ãã«ãããŸããã OKãã¯ãªãã¯ããŸãã Rolesã¯ã©ãŠããããžã§ã¯ãã§WorkerRoleWithSBQueue 1ã2åå³ã¯ãªãã¯ããŠãWorkerããŒã«ã管çããããã®GUIãéããŸãã
[ æ§æ ]ã¿ãã§ã[ 蚺æãæå¹ã«ãã ]ãªãã·ã§ã³ããªãã«ããŸãã [èšå® ]ã¿ãã«ç§»åãã [èšå®ã® è¿œå ]ãã¯ãªãã¯ããŠã storageaccountãšããæ°ããæ§æèšå®ãäœæããŸãã ãã®ã¿ã€ããæ¥ç¶æååãšããŠæå®ããçç¥èšå·ãã¿ã³ãã¯ãªãã¯ããŠæ¥ç¶æååãèšå®ããŸãã å¿ èŠãªããŒã¿ã¯ããŒã1ã§èšé²ãããŸããã [ OK]ãã¯ãªãã¯ããŸãã æ¥ç¶æååã«å¿ èŠãªå€ã貌ãä»ããŠã Microsoft.ServiceBus.ConnectionStringãæ§æããŸãã å¿ èŠãªããŒã¿ã¯ããŒã1ã«èšé²ãããŸãã- ãšã³ããã€ã³ãããŒãã®ããŒã ã¹ããŒã¹åã SharedSecretIssuerã® ããã©ã«ãçºè¡è ãããã³SharedSecretValueã® ããã©ã«ãã㌠ã å€æŽãä¿åããŠãWorkerããŒã«ç®¡çã®ã°ã©ãã£ã«ã«ã€ã³ã¿ãŒãã§ã€ã¹ãéããŸãã
F5ããŒãæŒããŠãããžã§ã¯ããéå§ããŸãã ãããžã§ã¯ãã¯ããŒã«ã«ã³ã³ãã¥ãŒãã£ã³ã°ãšãã¥ã¬ãŒã¿ã§éå§ããã ããŒã /ã€ã³ããã¯ã¹ãã¥ãŒã§ãã©ãŠã¶ãèµ·åããŸãã
ç»åãéžæããŠ[ ä¿å ]ãã¯ãªãã¯ããŸã ã ç»åãèªã¿èŸŒãã åŸãããŒãžãæŽæ°ãããŸãã çŸæç¹ã§ã¯ãã¢ããããŒãããç»åã¯1ã€ãã衚瀺ãããŠããªãããšã«æ³šæããŠãã ããã ãã°ããããŠïŒãããæ°ç§ïŒããŒãžãæŽæ°ããŸã-ä»åºŠã¯ãã€ã¡ãŒãžããã»ããµããã¥ãŒãããŒãªã³ã°ããWebããŒã«ããã¡ãã»ãŒãžãåä¿¡ããããããããŠã³ããŒããããã®ã³ããŒãäœæããŠãæ°ãããããããªããžããªã«é 眮ããå¿ èŠããããŸãã
Visual Studio 2012ããã¯ã©ãŠããµãŒãã¹ã®Windows Azureãã©ãããã©ãŒã ã«ASP.NET MVC 4ã¢ããªã±ãŒã·ã§ã³ãå±éãã
Windows Azureãã©ãããã©ãŒã ã®ã¯ã©ãŠããµãŒãã¹ã«ã¢ããªã±ãŒã·ã§ã³ããããã€ããã«ã¯ãããã«å¿ããŠVisual Studio 2012ã®çºè¡æ©èœãæ§æããå¿ èŠããããŸãã
MVC 4 Galleryã¯ã©ãŠããããžã§ã¯ããå³ã¯ãªãã¯ããŸãã 玺Azure [ çºè¡]ãã¯ãªãã¯ããŸãã éãããã€ã¢ãã°ããã¯ã¹ã§ã[ ãµãã¹ã¯ãªãã·ã§ã³ã®éžæ ]ã®äžã®ãªã¹ããå±éãã[ <管ç...>]ãéžæããŸãïŒå³12ïŒã
å³ 12ã
衚瀺ãããWindows Azureã¯ã©ãŠããµãŒãã¹ã®ãããžã§ã¯ã管çãã€ã¢ãã°ããã¯ã¹ã§ã[ æ°èŠ ]ãã¯ãªãã¯ããŸãã ã¢ããªã±ãŒã·ã§ã³ã®ãããã€ã«äœ¿çšãããæ°ãã蚌ææžã®é©åãªååãå ¥åããŸãã [ OK]ãã¯ãªãã¯ããŸãã [ ãã«ãã¹ã®ã³ããŒ]ãªã³ã¯ãã¯ãªãã¯ããŸãã Windows Azure管çããŒã¿ã«ã«ç§»åããŸãã [ ãã¹ããããµãŒãã¹ãã¹ãã¬ãŒãžã¢ã«ãŠã³ããCDN ]ã¿ããã¯ãªãã¯ããŸãã ã [ 管ç蚌ææž ]ã¿ããã¯ãªãã¯ããŸãã ã [ 管ç蚌ææž ]ã¿ãã§ã[ 蚌ææžã®è¿œå ]ãã¯ãªãã¯ããŸãã éãã[ æ°ãã管ç蚌ææžã®è¿œå ]ãã€ã¢ãã°ããã¯ã¹ã§ã[ åç § ]ãã¯ãªãã¯ããVisual Studioããã³ããŒãã蚌ææžãã¹ã[ãã¡ã€ã«å]ãã£ãŒã«ãã«è²Œãä»ããŸãã éããã¯ãªãã¯ããŸãã OKãã¯ãªãã¯ããŸãã [ ãã¹ããããµãŒãã¹ ]ã¿ãã«ç§»åãã[ ãããã㣠]ããã«ãããµãã¹ã¯ãªãã·ã§ã³IDãã³ããŒããŸã ã Visual Studio 2012ã«ç§»åããŸããã³ããŒãããµãã¹ã¯ãªãã·ã§ã³èå¥åã察å¿ãããã£ãŒã«ãã«è²Œãä»ããŸãïŒå³13ïŒã OKãã¯ãªãã¯ããŸãã
å³ 13ã
éãããã¯ãªãã¯ããŸã ã 次ãžãã¯ãªãã¯ããŸãã [Windows Azureã®å ¬éèšå®]ããŒãžã§ãè¿œå ã®å±éãªãã·ã§ã³ãæ§æã§ããŸãã [ å ¬é]ãã¯ãªãã¯ããŸãã Windows Azureã¢ã¯ãã£ããã£ãã°ãã¥ãŒã§å±éããã»ã¹ã確èªã§ããŸãïŒå³14ïŒã
å³ 14. Windows Azureã¢ã¯ãã£ããã£ãã°ã®è¡šç€º
[ ãã¹ãããããµãŒãã¹ ]ã¿ãã®Windows Azure管çããŒã¿ã«ã«ç§»åããŸãã ãããã€ãããã¢ããªã±ãŒã·ã§ã³ãéžæãã[ ãããã㣠]ããã«ã®[ DNSå]ãã£ãŒã«ãã®ãªã³ã¯ãã¯ãªãã¯ããŠãWebãµã€ãã«ç§»åããŸãïŒå³15ïŒã
å³ 15. Windows Azure管çããŒã¿ã«
ãµã€ãã¯ãããŒã«ã«ã³ã³ãã¥ãŒãã£ã³ã°ãšãã¥ã¬ãŒã¿ãŒã«å±éããåŸãšåãããã«èŠããããšã«æ³šæããŠãã ããã ããã¯ãã©ã¡ãã®å ŽåãWindows Azureã®å®éã®ã¹ãã¬ãŒãžã䜿çšãããããã§ãã æ°ããç»åãè¿œå ããŠãçµæã芳å¯ããŸãã