Azure应用程序服务秘密和网站隐藏的宝石

I just discovered that you can see a preview (almost like a daily build) of the Azure Portal if you go to https://preview.portal.azure.com instead of https://portal.azure.com. Sometimes the changes are big, sometimes they are subtle. It feels faster to me.

我刚刚发现,如果转到https://preview.portal.azure.com而不是https://portal.azure.com ,则可以看到Azure门户的预览(几乎类似于每日生成)。 有时变化很大,有时变化很小。 对我来说感觉更快。

Azure Preview Portal

A few days ago I blogged that I had found a number of things in Azure that I wasn't previously aware of like "Metrics per instance (App Service)" which is DEEPLY useful if you run more than one Web App inside an App Service Plan. Remember, an App Service Plan is basically a VM and you can run as many Websites, docker containers, Azure Functions, Mobile Apps, Api Apps, Logic apps, and whatever you can fit in there. Density is the word of the day.

几天前,我写了一篇博客,说我在Azure中发现了许多以前没有意识到的东西,例如“每个实例的指标(应用程序服务)”,如果您在一个应用程序服务中运行多个Web应用程序,这将非常有用计划。 记住,一个应用程序服务计划基本上是一个VM,您可以运行许多网站,docker容器,Azure函数,移动应用程序,Api应用程序,逻辑应用程序,以及其中可以容纳的任何内容。 密度是日常工作。

Azure应用程序服务的秘密和隐藏的宝石 (Azure App Service Secrets and Hidden Gems)

A bunch of folks agreed that there were some real hidden gems worth exploring so I thought I'd take a moment and do just that. Here's a few of the things that I'm continuously amazed are included for free with App Service.

一堆人都同意,有一些真正的隐藏宝石值得探索,所以我想我要花点时间来做。 App Service免费提供了一些让我不断惊奇的东西。

安慰 (Console)

The Console option under Development Tools

There's a web-based console that you can access from the Azure Portal to explore your apps!

您可以从Azure门户访问基于Web的控制台来浏览应用程序!

Live HTML5 Console within the Azure Portal

This is basically an HTML 5 bash prompt. I find it useful to double check the contents of certain files in Production, and confirm environment variables are set. I also, for some reason, find it comforting to see that my "cloud web site" actually lives on Drive D:. It calms me to know the Cloud has a D Drive.

这基本上是HTML 5 bash提示。 我发现仔细检查Production中某些文件的内容并确认设置了环境变量很有用。 出于某种原因,我也很高兴看到我的“云网站”实际上位于Drive D:上。 知道Cloud有D盘让我感到很高兴。

应用服务编辑器 (App Service Editor)

App Service Editor

App Service Editor is the editor that's codenamed "Monaco" that powers Visual Studio Code. It's amazing and few people know about it. I use it to make quick updates to production, although you do need to be aware if you have Continuous Deployment enabled that your changes will get eventually overwritten.

App Service编辑器是代号为“ Monaco”的编辑器,可为Visual Studio Code提供支持。 太神奇了,很少有人知道。 我使用它来快速更新生产,尽管您确实需要知道是否启用了持续部署,才能最终覆盖您的更改。

It's like a whole "IDE in the Cloud"

生产中的测试-(A / B测试) (Testing in Production - (A/B Testing))

This is an amazing feature that not enough people know about. So, I'm assuming you are aware of Staging Slots? These are things like dev-, test-, or staging- that you can pull from a different branch during CI/CD, or just a separate but near-identical website that runs on the same hardware. The REAL magic is the Testing in Production feature.

这是一个令人惊讶的功能,人们对此了解不足。 所以,我假设您知道分段插槽? 您可以在CI / CD期间从不同的分支机构中提取诸如dev,test或staging之类的东西,也可以是在相同硬件上运行的单独但近乎相同的网站。 真正的魔力在于生产测试功能

Once you have a slot - I have one here for the Staging Site for BabySmash - you have the option to just "swap" between staging and production...OR...you can set a percentage of traffic you want to go to each slot!

有了广告位-我在这里有一个BabySmash的登台站点-您可以选择在登台和生产之间“交换” ...或者...您可以设置要访问的流量百分比插槽!

Note that traffic is pinned to a slot for the life of a client session, so you don't have to worry about folks bouncing around if you change the UI or something.

请注意,在客户端会话的整个生命周期中,流量都固定在插槽中,因此,如果您更改UI或其他内容,您不必担心人们会跳来跳去。

Why is this insanely powerful? You can even make - for example - a "beta" slot and have your customers opt-in to a beta! And you don't have to write any code to enable this! MyApp.com/?x-ms-routing-name=beta would get them there and MyApp.com?x-ms-routing-name=self always points to Production.

为什么这如此强大? 您甚至可以创建一个“测试版”广告位,让您的客户选择加入测试版! 而且您无需编写任何代码即可启用此功能! MyApp.com/?x-ms-routing-name=beta将使它们到达那里,而MyApp.com?x-ms-routing-name=self始终指向生产。

Testing in Production

You could also write a PowerShell script that would slowly move traffic in increments. That way you could ramp up traffic to staging from 5% to 100% - assuming you see no errors or issues.

您还可以编写一个PowerShell脚本,该脚本将缓慢地逐步增加流量。 这样,您可以将流量从5%提升到100% -假设您没有看到错误或问题。

$siteName = "yourProductionSiteName"
$rule1 = New-Object Microsoft.WindowsAzure.Commands.Utilities.Websites.Services.WebEntities.RampUpRule
$rule1.ActionHostName = "yourSlotSiteName"
$rule1.ReroutePercentage = 10;
$rule1.Name = "stage"

$rule1.ChangeIntervalInMinutes = 10;
$rule1.ChangeStep = 5;
$rule1.MinReroutePercentage = 5;
$rule1.MaxReroutePercentage = 50;
$rule1.ChangeDecisionCallbackUrl = "callBackUrlOfyourChoice-OptionalThatDecidesIfYouShoudlKeepGoing"

Set-AzureWebsite $siteName -Slot Production -RoutingRules $rule1

All this stuff is built-in to the Standard Azure AppServicePlan.

所有这些内容都内置在标准Azure AppServicePlan中。

简单又便宜的数据库 (Easy and Cheap Databases)

A number of folks in the comments of my last post asked about the 20 websites I have running on my single App Service Plan. Some felt I may have been disingenuous about the pricing and assumed I have a bunch of SQL Server databases behind my sites, or that a site can't be useful without a SQL Server.

在上一篇文章的评论中,许多人问到我在单个App Service Plan上运行的20个网站。 有人认为我可能对价格不屑一顾,并认为我的站点后面有很多SQL Server数据库,或者如果没有SQL Server站点就无法使用。

There's a few things there to answer. My sites are many different techs, Node.js, Ruby, C# and ASP.NET MVC, and static sites. For example:

有几件事要回答。 我的网站有很多不同的技术,例如Node.js,Ruby,C#和ASP.NET MVC,以及静态网站。 例如:

  • Running the Ruby Middleman Static Site Generator on Microsoft Azure runs in the cloud when I check code into GitHub but deploys a static site.

    当我将代码检入GitHub但部署静态站点时,在Microsoft Azure上运行Ruby Middleman静态站点生成器将在云中运行。

  • The Hanselminutes Podcast uses WebMatrix and ASP.NET WebPage's "SQL Compact Edition." This database runs out of a single file that's stored locally.

    Hanselminutes播客使用WebMatrix和ASP.NET WebPage的“ SQL Compact Edition”。 该数据库用尽了本地存储的单个文件。
  • One of my node.js sites uses SQL Lite for its data.

    我的一个node.js站点使用SQL Lite来存储其数据。
  • One ASP.NET application uses "Azure MySQL in-app" that is also included in Azure App Service. You get a single modest MySQL database that runs in the context of your App Service. It's not super fast and meant for development, but with a little caching it's very workable.

    一个ASP.NET应用程序使用“ Azure MySQL应用程序内”,该应用程序包含在Azure App Service中。 您将获得一个在应用服务上下文中运行的普通MySQL数据库。 它不是超级快并且适合开发,但是只需一点缓存就可以了。

  • One node.js app thinks it is talking MongoDB but actually it's talking via MongoDB protocol support in Azure DocumentDB. You can create an Azure noSQL DocumentDB and point any app that speaks Mongo to it and it Just Works.

    一个node.js应用程序认为它正在使用MongoDB,但实际上它是通过Azure DocumentDB中的MongoDB协议支持进行通信。 您可以创建一个Azure noSQL DocumentDB,然后将任何使用Mongo的应用程序指向它,并且该应用程序可以正常工作。

There's a number of options, including Easy Tables for your Mobile Apps. Check out http://mobile.azure.com to learn more about how you can get a VERY quick and easy backend for mobile (or web) apps.

有很多选项,包括适用于您的Mobile Apps的Easy Tables 。 请访问http://mobile.azure.com,以了解更多有关如何为移动(或Web)应用程序获得非常快速便捷的后端的信息。

Azure应用服务扩展 (Azure App Service Extensions)

If you have used Git deploy to an Azure App Service, you likely noticed a "Sidecar" website that your app has. I have babysmash.com which is actually babysmash.azurewebsites.net, right? There's also babysmash.scm.azurewebsites.net that you can't access. That sidecar site (when I'm authenticated) has a ton of easy REST GET APIs I can call to get my process list, files, deployments, and lots more. This is all powered by Kudu, which is open source by the way.

如果您已使用Git部署到Azure App Service,则可能会注意到您的应用程序具有一个“ Sidecar”网站。 我有babysmash.com,实际上是babysmash.azurewebsites.net,对吗? 还有无法访问的babysmash.scm.azurewebsites.net。 该Sidecar网站(通过身份验证后)具有大量易于使用的REST GET API,我可以调用它们来获取我的进程列表,文件,部署以及更多内容。 这全部由Kudu提供支持,而Kudu则是开源的

The Azure Kudu sidecar site

Kudu's sidecar site is a "site extension." You can not only write your own Azure Site Extension (they are just NuGet packages!) but it turns out there are a TON of useful already vetted and published extensions you can add to your site today. Those extensions live at http://www.siteextensions.net but you add them directly from the Azure Portal. There's 84 at the time of this blog post.

Kudu的辅助站点是“站点扩展”。 您不仅可以编写自己的Azure网站扩展(它们只是NuGet包!),事实证明,有很多有用的已经经过审核和发布的扩展,您可以在今天添加到您的网站中。 这些扩展位于http://www.siteextensions.net,但您可以直接从Azure门户添加它们。 这篇博客发布时有84个。

Azure Site Extensions include:

Azure网站扩展包括:

  • phpMyAdmin - for Admin of MySQL over the web

    phpMyAdmin-通过Web进行MySQL的管理
  • Azure Let's Encrypt - Easy install of Let's Encrypt SSL certs!

    Azure Let's Encrypt-轻松安装Let's Encrypt SSL证书!
  • Image Optimizer - Automatic squishing of your site's JPGs and PNGs because you know you forgot!

    图像优化器-自动压缩站点的JPG和PNG,因为您知道自己忘记了!
  • GoLang Support - Azure doesn't officially support Go in Azure Web Apps...but with this extension it works fine!

    GoLang支持-Azure尚未正式支持Azure Web Apps中的Go ...但是使用此扩展,它可以正常工作!
  • Jekyll - Easy static site generation in Azure

    Jekyll-在Azure中轻松生成静态站点
  • Brotli HTTP Compression

    Brotli HTTP压缩

You get the idea.

你明白了。

诊断程序 (Diagnostics)

I just discovered this "uptime" blade within my Web Apps in the Azure Portal. It tells me my app's uptime and if it's not 100%, it tells my why not and when!

我刚刚在Azure门户的Web应用程序中发现了这个“正常运行时间”刀片。 它告诉我我的应用程序的正常运行时间,如果不是100%,它告诉我为什么不这样做以及何时!

Azure Diagnostics and Uptime

Again, none of this stuff costs extra. You can add Site Extensions or explore your apps to the limit of the underlying App Service Plan. I'm doing all this on a single Standard 1 (S1) App Service Plan.

同样,这些东西都不需额外付费。 您可以添加网站扩展或在基础应用服务计划的限制范围内浏览您的应用。 我在单个Standard 1(S1)App Service Plan上完成所有这些工作。

Sponsor: Excited about the future in ASP.NET? The folks at Progress held an awesome webinar which gives a 360⁰ view of the new ASP.NET Core and how it compares to WebForms and MVC. Watch it now on demand!

赞助者:对ASP.NET的未来感到兴奋吗? Progress的人们举办了一个很棒的网络研讨会,可以360°观看新的ASP.NET Core及其与WebForms和MVC的比较。 现在点播观看!

翻译自: https://www.hanselman.com/blog/azure-app-service-secrets-and-web-site-hidden-gems

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值