henny penny视频_Penny Pinching视频:将我的网站的图像移动到Azure CDN(并使用自定义域)

henny penny视频

henny penny视频

I talked about Pinching pennies when scaling in The Cloud last week when I added jQuery lazy loading to my podcast's Website. Next, I moved my website to the same data center as my SQL Database (in fact, they should have always been together!). Now, I'm moving all my show images to the Azure CDN. There's been ~370 shows, and if someone visits the archives page and scrolls around it's about 8 megs of pics.

上周,当我在播客的Website上添加jQuery延迟加载时,我谈到了在The Cloud上进行扩展时的捏钱问题。 接下来,我将网站移至与SQL数据库相同的数据中心(实际上,它们应该一直在一起!)。 现在,我将所有显示图像移动到Azure CDN。 大约有370场演出,如果有人访问档案页面并滚动浏览,则大约有8兆的图片。

CDN Metrics are looking great

Additionally, I have a very international group who listen to my podcast, so by moving the images to the CDN I'll get load balancing and edge caching as well. Asians will get the images served from an Asian data center, etc.

此外,我有一个非常国际化的小组来收听我的播客,因此通过将图像移到CDN上,我还将获得负载平衡和边缘缓存。 亚洲人将从亚洲数据中心等处获取图像。

Now, to be clear, Azure bandwidth is pretty cheap, with even 100GB costing around ~$11, but I also wanted to learn how to use Blob Storage and the CDN. I've only used it to store Virtual Machines and it's been hidden from me. Bandwidth from the Azure CDN is about the same price, but I get the geo-replication for free. Remember also that "ingress," that is, incoming traffic, is free. When you're estimating your bandwidth costs, you're only worried about outgoing traffic.

现在,要明确一点,Azure带宽相当便宜,甚至100GB的价格都在11美元左右,但是我还想学习如何使用Blob存储和CDN。 我只用它来存储虚拟机,但对我来说它是隐藏的。 Azure CDN的带宽价格大致相同,但我可以免费获得地理复制。 还请记住,“进入”(即传入流量)是免费的。 在估算带宽成本时,您只担心外向流量。

I also thought it would be cool to have a custom Hanselminutes subdomain, so I want the images to be served from http://images.hanselminutes.com, because it's cool. Plus, it means I could switch CDNs in the future and not change my URLs.

我还认为拥有一个自定义的Hanselminutes子域会很酷,所以我希望从http://images.hanselminutes.com提供图像,因为它很酷。 另外,这意味着我将来可以切换CDN,而无需更改URL。

Here's the steps I used:

这是我使用的步骤

  • I created a new storage account called 'hanselminutescdn,' then a container called 'images.'

    我创建了一个名为“ hanselminutescdn”的新存储帐户,然后创建了一个名为“ images”的容器。
  • I went to 'Configure' and setup the images.hanselminutes.com CNAME to point to the new storage account. I went to my DNS provider (DNSimple.com) and added a CName from images.hanselman.com to point to hanselminutescdn.blob.core.windows.net, and then verified the domain per the Azure portable instructions. This involved adding another verification-specific CNAME.

    我转到“配置”并设置images.hanselminutes.com CNAME指向新的存储帐户。 我去了我的DNS提供商( DNSimple.com ),从images.hanselman.com添加了一个CName指向hanselminutescdn.blob.core.windows.net,然后根据Azure可移植指令进行了验证。 这涉及添加另一个特定于验证的CNAME。

A custom Azure CNAME for my Domain
  • I downloaded the Azure SDK for .NET and used Visual Studio to upload the images.

    我下载了适用于.NETAzure SDK,并使用Visual Studio上传了图像。

    I downloaded the Azure SDK for .NET and used Visual Studio to upload the images.  
    我下载了 适用于.NETAzure SDK,并使用Visual Studio上传了图像。
    image
  • Later after the video, I got CloudBerry Explorer for Windows Azure and used their "sync" option to keep my local show images folder and Azure in sync. Very slick. Their app also lets me easily set HTTP Headers on my images if I want. I may pay for the Pro version.

    视频播放后,我获得了适用于Windows Azure的CloudBerry Explorer 并使用其“同步”选项使本地显示图像文件夹和Azure保持同步。 很好吃他们的应用程序还让我可以根据需要轻松地在图像上设置HTTP标头。 我可以为Pro版本付费。

    CloudBerry Explorer for Windows Azure适用于Windows Azure的CloudBerry Explorer and used their "sync" option to keep my local show images folder and Azure in sync. Very slick. Their app also lets me easily set HTTP Headers on my images if I want. I may pay for the Pro version. 并使用其“同步”选项使本地显示图像文件夹和Azure保持同步。 很好吃他们的应用程序还让我可以根据需要轻松地在图像上设置HTTP标头。 我可以为Pro版本付费。
    Cloud Berry Explorer
  • I changed my paths in my HTML to images.hanselminutes.com instead of just /images of the website's domain.

    我将HTML中的路径更改为images.hanselminutes.com,而不仅仅是网站域的/ images。
  • I discovered that CDNs are case sensitive, then ran this PowerShell Script to make ALL my show images files all lowercase.

    我发现CDN区分大小写,然后运行此PowerShell脚本使我的所有显示图像文件都变为小写。
dir | Rename-Item { $_.Name.ToLowerInvariant() }
  • I cleared out the files and reuploaded the new lower-case ones.

    我清除了文件,然后重新上传了新的小写字母。
  • PROFIT.

    利润。

OK, I haven't figured out that last step, but soon...very soon. ;)

好的,我还没有弄清楚最后一步,但是很快……很快。 ;)

IMPORTANT UPDATE: Commenter Nate Jackson points out that while I've setup access to blob storage, I haven't yet actually enable the Edge Caching abilities of the CDN itself. For this, it seems I have to visit the old management portal (which explains why I missed it completely. It's not intuitive!).

重要更新:评论员Nate Jackson指出,尽管我已经设置了对Blob存储的访问权限,但我尚未真正启用CDN本身的边缘缓存功能。 为此,似乎我必须访问旧的管理门户(这说明了为什么我完全错过了它。这不直观!)。

You get to the old portal from your account dropdown:

您可以从帐户下拉列表转到旧门户:

Switching over to the Previous Portal

There's instructions on the Azure docs site the say I need to create a "CDN endpoint" that associates the CDN with my now-public blob storage container.

Azure文档站点上说明,要求我创建一个“ CDN终结点”,以将CDN与我现在公开的Blob存储容器相关联。

I visit the Hosted Accounts + CDN button, then click New Endpoint.

我访问托管帐户+ CDN按钮,然后单击“新建端点”。

Creating a CDN Endpoint

The URL template looks like this.

URL模板如下所示。

http://<CDNNamespace>.vo.msecnd.net/<myPublicContainer>/<BlobName>

http:// < CDNNamespace > .vo.msecnd.net / < myPublicContainer > / < BlobName >

So after clicking new CDN endpoint and enabling the CDN, I'm told my CDN endpoint name is "az415467" per the old portal:

因此,在单击新的CDN端点并启用CDN之后,会告诉我,每个旧门户的CDN端点名称为“ az415467”:

Making a new CDN endpoint I'm given a unique URL

Given the URL template a URL from my container would be:

给定URL模板,来自我的容器的URL将是:

http://az415467.vo.msecnd.net/images/255.jpg

http://az415467.vo.msecnd.net/images/255.jpg

Then (if you want) click Add Custom Domain:

然后(如果需要)单击添加自定义域:

Associating my custom domain with my new CDN endpoint

Then point the domain to the CDN, not to public blob storage:

然后将域指向CDN,而不是公共Blob存储:

Pointing my custom domain to the CDN

At this point the old management portal looks like this:

此时,旧的管理门户看起来像这样:

Now my blob is associated with my custom domain name

And I can confirm it works when I visit

我可以确认当我造访时

http://az415467.vo.msecnd.net/images/255.jpg  as well as http://images.hanselminutes.com/images/255.jpg

http://az415467.vo.msecnd.net/images/255.jpg以及http://images.hanselminutes.com/images/255.jpg

So the idea is that there's storage in general, there's blob storage made public (which is what I did) which can be geo-replicated, and then there's the formal geo-load-balanced Content Delivery Network, which I failed to configure!

因此,我们的想法是通常有一个存储,有一个公开的Blob存储(这就是我所做的),可以进行地理复制,然后有一个正式的地理负载平衡的Content Delivery Network,我无法对其进行配置!

CDN -> pulls from -> Public Blob Endpoint -> hosted in -> Your Storage Container itself

CDN->从->公共Blob端点->托管在->您的存储容器本身中

I will update the YouTube video soon. Big thanks to Nate Jackson for catching this oversight and educating me!

我将尽快更新YouTube视频。 非常感谢Nate Jackson 受到这种疏忽并教育我!

相关链接 (Related Links)

Sponsor: The Windows Azure Developer Challenge is on.  Complete 5 programming challenges for a chance at spot prizes, Stage prizes and the Grand Prize. Over $16,000 is up for grabs with 65 chances to win!

赞助商: Windows Azure开发人员挑战赛即将开始。 完成5个编程挑战,有机会获得现场奖,舞台奖和大奖。 超过$ 16,000的奖金有65个获胜的机会!

翻译自: https://www.hanselman.com/blog/penny-pinching-video-moving-my-websites-images-to-the-azure-cdn-and-using-a-custom-domain

henny penny视频

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值