简体   繁体   English

从本地IIS应用程序访问Azure Blob存储

[英]Access Azure Blob Storage from on-premises IIS application

I have an on premises .NET/IIS application for which I have developed new functionality to allow users to upload images to Azure Blob Storage. 我有一个本地.NET / IIS应用程序,为此我开发了新功能,以允许用户将图像上传到Azure Blob存储。 Everything works fine in my development environment, and now I am ready to deploy this application on premises to my production environment. 一切在我的开发环境中都可以正常工作,现在我可以将该应用程序在本地部署到生产环境中了。

I can't figure out how to do this. 我不知道该怎么做。 Is it possible? 可能吗? If so, how do I do this? 如果是这样,我该怎么做?

A little more detail: 更多细节:

  • My environment is Windows Server 2008 R2 running IIS 7.5 我的环境是运行IIS 7.5的Windows Server 2008 R2
  • The service connects to the actual Azure Blob Storage in the cloud, and I can save images online (that is, I log into my account on the Azure portal and I can see the images uploaded in my test container) from my development environment (VS 2013 with IIS Express) using the Azure Development Compute/Storage Emulator from Azure SDK 3.3. 该服务连接到云中的实际Azure Blob存储,并且可以从开发环境(VS)在线保存图像(即,我登录到Azure门户上的帐户,并且可以看到在测试容器中上传的图像)。 2013年(使用IIS Express的IIS Express),使用Azure SDK 3.3中的Azure开发计算/存储模拟器。
  • I cannot get the solution working on my development box(es) using IIS 7.5. 我无法使用IIS 7.5在我的开发盒上使用该解决方案。
  • I have tried "Deploy" the solution from the "Build" menu in my solution, but nothing happens. 我已经尝试从解决方案的“构建”菜单中“部署”解决方案,但是什么也没有发生。 Attempting to "Publish" the Cloud Service Project in my solution just takes me to Azure to publish it online. 尝试在解决方案中“发布” Cloud Service Project只是将我带到Azure进行在线发布。 Is that what is necessary to get my solution working? 这是使我的解决方案正常工作所必需的吗? Publishing the Cloud Service project? 发布云服务项目?

Thanks. 谢谢。

If all you have is a web application that you are deploying on-premises, you should not be using a Cloud Service project (which is a project that is ultimately deployed as an Azure Cloud Service). 如果仅拥有要在本地部署的Web应用程序,则不应使用Cloud Service项目(该项目最终将作为Azure Cloud Service部署)。 If you want the blob uploads to occur on the web server, you just need to add the Azure Storage NuGet package to your web project and use the storage libraries to upload the blobs (assuming you already have code like this somewhere since you say things are working on your dev box). 如果要在Web服务器上进行Blob上传,则只需将Azure Storage NuGet程序包添加到Web项目中,然后使用存储库上传Blob(假定您已经在某处拥有这样的代码,因为您说的是在您的开发箱上工作)。

I think the answer to my question is basically to ignore the cloud service project entirely and just deploy the underlying website as you would ordinarily deploy it, with two minor modifications. 我认为,我的问题的答案基本上是完全忽略云服务项目,仅按常规部署基础站点的方式进行部署,但有两个较小的修改。

  1. Add your Azure Blob connection string in your Web.config file so that you can access it from your project without needing to reference the Cloud Storage Account settings (ie, CloudConfigurationManager.GetSetting, etc.). 在Web.config文件中添加Azure Blob连接字符串,以便您可以从项目中访问它,而无需引用Cloud Storage帐户设置(即CloudConfigurationManager.GetSetting等)。
  2. In your Web.config file, comment out the AzureDiagnostics trace listeners: 在您的Web.config文件中,注释掉AzureDiagnostics跟踪侦听器:

      <listeners> <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics"> <filter type="" /> </add> 

Using these two modifications, I was able to deploy my underlying website to my local IIS while still accessing Azure Blob Storage from my on-premises solution. 使用这两个修改,我能够将基础网站部署到本地IIS,同时仍然可以从本地解决方案访问Azure Blob存储。

I am still not entirely sure whether I ever even needed or still need the Cloud Services project in my solution at all, but I am keeping it there for now. 我仍然不确定我的解决方案中是否需要甚至根本不需要Cloud Services项目,但是我现在将其保留在那里。

Hopefully, this question/answer will help somebody else searching for documentation on a hybrid on-premises and Azure solution since there really seems to be almost nothing out there on this subject. 希望这个问题/答案可以帮助其他人搜索有关混合本地和Azure解决方案的文档,因为关于该主题实际上似乎几乎没有任何东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM