天青,存储和部署静态内容最好的方式(例如图像/ CSS)? [英] Azure, best way to store and deploy static content (e.g. images/css)?

查看:233
本文介绍了天青,存储和部署静态内容最好的方式(例如图像/ CSS)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们即将我们的.NET Web应用程序部署到Azure的Web角色。我只是想知道其他人如何处理它们的静态内容,特别是图像和CSS?目前,我们的应用程序包是约25MB,但是那18MB是从纯粹的图像衍生,像导航按钮,图标和模板组件,很少能得到更新。难道是明智的,这个划分出来的部署包,并将其移动到Blob存储?

我对这种做法的几个疑问,我想知道是有效的...


  1. 我们网站的80%,在HTTPS环境中运行。将在BLOB存储访问图像引入跨脚本问题?


  2. 漏洞钱泄漏,如果有人试图恶意锤我们的图像(大部分是在20KB)


  3. 我挣扎,看它如何可能将文件上传到一个blob容器(从VS2010 +的Azure SDK)与目录命名规则,所以我不需要重写路径引用的1000?我AP preciate目录在BLOB容器一个抽象的概念,但我可以用斜杠在code模仿这个写文件。显然,Windows不允许我之前在Visual Studio中上传我做到这一点。


任何想法或替代战略将受到欢迎。我们的目标真的是缩小我们的部署包,以加快部署时间。此外,我很喜欢服务卸载到专用节点形象,提高Web服务器的性能的想法,也许我的图像采集是如此之小,几乎不值得困扰?

5月16日更新----------------------------------------- -------------------------------

这就是我到底做了:

1.Transferred所有图像+ CSS来Blob存储容器。我维护的任何子目录结构的图像和CSS文件夹中。

2.产品使用在我们的web.config文件的URL重写规则如下。

 <&改写GT;
    <规则与GT;
      <规则名称=imagestoazure>
      <匹配URL =图片/(.*)/>
      <作用TYPE =重定向URL =htt​​ps://xxxxx.vo.msecnd.net/images/{R:1}/>
    < /规则>
  < /规则>
  < /重写>

3.Excluded来自应用程序的图像+ CSS文件夹和部署。

我的部署是现在小得多,图像被流失CDN的释放带宽,提高下载速度和释放一些负载关闭web服务器

更新:2015年9月

回顾当这个最近我碰到来自微软以下指南。它进入更详细的关于如何使用查询字符串自动化资产的部署和缓存的半身像。

<一个href=\"https://azure.microsoft.com/en-us/documentation/articles/cdn-serve-content-from-cdn-in-your-web-application/\"相对=nofollow>在Web应用程序即成从Azure的CDN内容


解决方案

一些评论:


  

难道是明智的,这个划分出来的部署包,并将其移动到Blob存储?


当然可以。我可以看到这样做有很多好处:


  1. 正如你提到的,这将大大从而降低你的封装尺寸变得部署更快。

  2. 同样,你所提到的,它会采取负载关闭您的Web服务器这样会让你的网站的响应速度。

  3. 如果您需要更新图片,JS,CSS文件,你可以只更换Blob存储这些文件。如果他们在你的包被留下,你就需要重新部署你的包。

  4. 您也可以利用的Windows Azure CDN的其中工程关Blob存储的。


  

我们网站的80%,在HTTPS环境中运行。在访问图像
  一个blob店推出跨脚本问题?


只要你不通过AJAX阅读的内容,我不认为你会碰到交叉脚本问题(<一个href=\"http://stackoverflow.com/questions/15135089/how-to-access-xml-hosted-as-azure-blob-from-azure-website/15136051#comment21418042_15136051\">How访问XML托管从蔚蓝的网站蔚蓝BLOB)。但是,如果你的页面被通过HTTPS服务,你通过HTTP引用静态资源,您的用户可能会得到混合的内容(有担保和无担保的)消息。


  

漏洞钱泄漏,如果有人试图恶意
  锤我们的图像(大部分是在20KB)?


请看看这里的出口带宽定价:<一href=\"http://www.windowsazure.com/en-us/pricing/details/#header-11\">http://www.windowsazure.com/en-us/pricing/details/#header-11.目前,Windows Azure中运行的是推广有多达5 GB的数据转出是免费的,它是$ 0.12 / GB这是相当便宜。您还需要采取存储事务考虑这也是很便宜的。我不会太担心了。在最坏的情况下,你总是可以恢复到共享访问签名和保护资源。


  

我挣扎,看它如何可能将文件上传到一个blob
  集装箱(从VS2010 +的Azure SDK)与目录的命名规则
  所以我并不需要重写路径引用的1000?我AP preciate
  目录在BLOB容器一个抽象的概念,但我可以
  写文件以正斜杠在code模仿这一点。明显
  Windows不允许我这样做之前,我在Visual Studio中上传


有是一些可供您使用第三方工具在Blob存储上传时,将preserve本地计算机上的文件夹结构。请看一看从Windows Azure存储团队这个博客帖子:<一href=\"http://blogs.msdn.com/b/windowsazurestorage/archive/2010/04/17/windows-azure-storage-explorers.aspx\">http://blogs.msdn.com/b/windowsazurestorage/archive/2010/04/17/windows-azure-storage-explorers.aspx.显然,我个人最喜欢的是从Cerebrata云存储工作室:) [我是开发者为该产品之一]

We're about to deploy our .NET web application to an Azure Web Role. I'm just wondering how others have handled their static content, specifically images and css? At the moment our application package is about 25mb but 18mb of that is derived purely from images, things like navigation buttons, icons and template components that rarely ever get updated. Would it be wise to partition this out of the deployment package and move it to blob storage?

I have a few doubts about this approach that I'm wondering are valid...

  1. 80% of our site runs in a HTTPS environment. Will accessing images in a blob store introduce cross-scripting problems?

  2. Vulnerability to money leakages, if someone tries to maliciously hammer our images (most are under 20kb)?

  3. I'm struggling to see how it's possible to upload files to a blob container (from VS2010 + Azure SDK) with directory naming convention so I don't need to rewrite 1000s of path references? I appreciate directories are an abstract concept in blob containers, but I can write files with a forward slash to imitate this in code. Obviously Windows does not allow me to do this before I upload in Visual Studio.

Any thoughts or alternative strategies would be welcome. The goal really is to shrink our deployment package to speed up the deploy time. Also I quite like the idea of offloading the image serving to a dedicated node to improve the performance on the web server, maybe my image collection is so small that it's hardly worth bothering?

Update 16th May ------------------------------------------------------------------------

Here's what I did in the end:

1.Transferred all images + css to blob storage containers. I maintained the structure of any sub-directories within the images and css folders.

2.Applied a URL Rewrite rule in our web.config file as follows..

  <rewrite>
    <rules>
      <rule name="imagestoazure">
      <match url="images/(.*)" />
      <action type="Redirect" url="https://xxxxx.vo.msecnd.net/images/{R:1}" />
    </rule>
  </rules>
  </rewrite>

3.Excluded the images + css folders from the application and deployed.

My deployment is now much smaller and the images are running off a CDN freeing up bandwidth, improving downloads speeds and releasing some load off the web-server.

Update: September 2015

When reviewing this recently I came across the following guide from Microsoft. It goes into more detail about how you can automate the deployment of your assets and cache bust using querystrings.

Serve Content from Azure CDN in Your Web Application

解决方案

Some comments:

Would it be wise to partition this out of the deployment package and move it to blob storage?

Absolutely. I can see many benefits of doing this:

  1. As you mentioned, this would reduce your package size considerably thus deployment becomes much faster.
  2. Again as you mentioned, it would take the load off of your web server thus will make your site more responsive.
  3. If you need to update images, js, css files you can just replace those files in blob storage. If they were left in your package, you would need to redeploy your package.
  4. You could also take advantage of Windows Azure CDN which works off of blob storage.

80% of our site runs in a HTTPS environment. Will accessing images in a blob store introduce cross-scripting problems?

As long as you're not reading the contents through AJAX, I don't think you'll run into cross-scripting issues (How to access XML hosted as azure blob from azure website). However if your page is served via https and you reference static resources via http, your users might get mixed content (secured and unsecured) message.

Vulnerability to money leakages, if someone tries to maliciously hammer our images (most are under 20kb)?

Do take a look at the outbound bandwidth pricing here: http://www.windowsazure.com/en-us/pricing/details/#header-11. Currently Windows Azure is running a promotion where up to 5 GB of data transfer out is free and it's $0.12 / GB which is quite cheap. You would also need to take storage transactions into consideration which is also very cheap. I wouldn't worry too much about it. In the worst case scenario, you could always revert to shared access signature and protect the resources.

I'm struggling to see how it's possible to upload files to a blob container (from VS2010 + Azure SDK) with directory naming convention so I don't need to rewrite 1000s of path references? I appreciate directories are an abstract concept in blob containers, but I can write files with a forward slash to imitate this in code. Obviously Windows does not allow me to do this before I upload in Visual Studio.

There're a number of 3rd party tools available to you which will preserve the folder structure of your local computer when uploading in blob storage. Do take a look at this blog post from Windows Azure Storage team: http://blogs.msdn.com/b/windowsazurestorage/archive/2010/04/17/windows-azure-storage-explorers.aspx. Obviously my personal favorite is Cloud Storage Studio from Cerebrata :) [I'm one of the devs for that product]

这篇关于天青,存储和部署静态内容最好的方式(例如图像/ CSS)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆