Windows Azure Media Storage for Azure Website.

Topics: Customizing Orchard
Jul 1, 2014 at 9:32 PM
Using Orchard 1.8.0. I have an Azure website, with Azure db and blob storage. In order to store my documents on Azure blob, I followed this process based on the documentation:
1. Deploy the cloud service.
2. In the management portal, navigate to your cloud service and select the Configure tab.
3. Under Orchard.Azure.Web locate the setting Orchard.Azure.Media.StorageConnectionString.
4. Set it to be the connection string of the storage account in which you want to store media content.
5. Click Save.
6. You can now enable the feature Windows Azure Media Storage in the admin dashboard.
My pages are loading fine on the Azure production site, but I am getting a connection string error on my local machine (which uses the same Azure db and blob storage as the Azure production site).

How do I get my local instance to play nice with Azure media storage?
Value cannot be null.
Parameter name: connectionString

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: connectionString

Source Error: 


Line 1:  @{
Line 2:      Orchard.ContentManagement.ContentItem contentItem = Model.ContentPart.ContentItem;
Line 3:      string title = Model.Title.ToString();
Line 4:  }
Line 5:  

Source File: c:\Projects\NPLCC-Orchard\src\Orchard.Web\Themes\NPLCC\Views\Parts.Title.Summary-Document.cshtml    Line: 3 

Stack Trace: 


[ArgumentNullException: Value cannot be null.
Parameter name: connectionString]
   Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(String connectionString) +234
   Orchard.Azure.Services.FileSystems.AzureFileSystem.EnsureInitialized() +104
   Orchard.Azure.Services.FileSystems.AzureFileSystem.get_Container() +37
   Orchard.Azure.Services.FileSystems.AzureFileSystem.GetPublicUrl(String path) +88
   Orchard.MediaLibrary.Services.MediaLibraryService.GetPublicUrl(String relativePath) +67
   Orchard.MediaLibrary.Services.MediaLibraryService.GetMediaPublicUrl(String mediaPath, String fileName) +74
   Orchard.MediaLibrary.Handlers.<>c__DisplayClass12.<.ctor>b__2(String x) +104
   Orchard.ContentManagement.Utilities.LazyField`1.GetValue() in c:\Projects\Orchard 1.8\src\Orchard\ContentManagement\Utilities\LazyField.cs:24
   Orchard.ContentManagement.Utilities.LazyField`1.get_Value() in c:\Projects\Orchard 1.8\src\Orchard\ContentManagement\Utilities\LazyField.cs:10
   Orchard.MediaLibrary.Models.MediaPart.get_MediaUrl() +46
   CallSite.Target(Closure , CallSite , Object ) +93
   ASP._Page_Themes_NPLCC_Views_Parts_Title_Summary_Document_cshtml.Execute() in c:\Projects\NPLCC-Orchard\src\Orchard.Web\Themes\NPLCC\Views\Parts.Title.Summary-Document.cshtml:3
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +199
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +256
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
   System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +277
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +91
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model) +33
   Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.Render(ShapeDescriptor shapeDescriptor, DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo, HarvestShapeHit harvestShapeHit) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:151
   Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.<>c__DisplayClass28.<Discover>b__15(DisplayContext displayContext) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:133
   Orchard.DisplayManagement.Descriptors.<>c__DisplayClass5.<BoundAs>b__2(DisplayContext displayContext) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:56
   Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:185
   Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:94
   Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:86
   Orchard.DisplayManagement.Implementation.DisplayHelper.Invoke(String name, INamedEnumerable`1 parameters) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:44
   Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object& result) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:29
   CallSite.Target(Closure , CallSite , Object , Object ) +193
   Orchard.Core.Shapes.CoreShapes.ContentZone(Object Display, Object Shape, TextWriter Output) in c:\Projects\NPLCC-Orchard\src\Orchard.Web\Core\Shapes\CoreShapes.cs:274

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +92
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +108
   System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +19
   Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy.ShapeAttributeBindingStrategy.PerformInvoke(DisplayContext displayContext, MethodInfo methodInfo, Object serviceInstance) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Descriptors\ShapeAttributeStrategy\ShapeAttributeBindingStrategy.cs:64
   Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy.<>c__DisplayClass4.<CreateDelegate>b__3(DisplayContext context) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Descriptors\ShapeAttributeStrategy\ShapeAttributeBindingStrategy.cs:55
   Orchard.DisplayManagement.Descriptors.<>c__DisplayClass5.<BoundAs>b__2(DisplayContext displayContext) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Descriptors\ShapeAlterationBuilder.cs:56
   Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Process(ShapeBinding shapeBinding, IShape shape, DisplayContext context) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:185
   Orchard.DisplayManagement.Implementation.DefaultDisplayManager.Execute(DisplayContext context) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:94
   Orchard.DisplayManagement.Implementation.DisplayHelper.ShapeExecute(Object shape) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:86
   Orchard.DisplayManagement.Implementation.DisplayHelper.Invoke(String name, INamedEnumerable`1 parameters) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:44
   Orchard.DisplayManagement.Implementation.DisplayHelper.TryInvoke(InvokeBinder binder, Object[] args, Object& result) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Implementation\DisplayHelper.cs:29
   CallSite.Target(Closure , CallSite , Object , Object ) +193
   ASP._Page_Modules_Orchard_MediaLibrary_Views_Media_Summary_cshtml.Execute() in c:\Projects\NPLCC-Orchard\src\Orchard.Web\Modules\Orchard.MediaLibrary\Views\Media.Summary.cshtml:9
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +199
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +256
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
   System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +277
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +91
   System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model) +33
   Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy.ShapeTemplateBindingStrategy.Render(ShapeDescriptor shapeDescriptor, DisplayContext displayContext, HarvestShapeInfo harvestShapeInfo, HarvestShapeHit harvestShapeHit) in c:\Projects\Orchard 1.8\src\Orchard\DisplayManagement\Descriptors\ShapeTemplateStrategy\ShapeTemplateBindingStrategy.cs:151...
Jul 14, 2014 at 7:21 PM
I have solved this by adding the following to the Orchard.Web/Web.config.

<appSettings>
   <add key="Orchard.Azure.Media.StorageConnectionString" value="[storageConnectionString]"/>
</appSettings>

I had tried this, before and it didn't work. Then added it again, restarted the app and rebuilt for good measure, and it took. Now my Azure Blob media files show up fine on my local machine.
Marked as answer by remsleepwagon on 7/14/2014 at 11:22 AM