mac azure git_将网站移至Azure,同时从Git添加持续部署

mac azure git

mac azure git

I've got this little one page website I wrote a few years ago that attempts to detect the version of the .NET Framework you have and give you a download for the smallest redist you need to get up to date. It's called SmallestDotNet.  It was written and thrown up while watching an hour of TV. Fortunately or unfortunately this little throwaway still gets about 10,000 page views a month. It also has a tiny JSON API that a lot of people have actually embedded into their sites and products.

我有几年前写的这个只有一页的网站,网站试图检测您拥有的.NET Framework版本,并为您提供最新版本所需的最小redist的下载。 它称为SmallestDotNet 。 它是在观看一个小时的电视时被编写并抛出的。 幸运的是或不幸的是,这个小小的弃用每月仍可获得约10,000次页面浏览。 它还有一个很小的JSON API,很多人实际上已经将其嵌入到他们的网站和产品中。

Additionally, it's starting to break. IE9+ doesn't include .NET Framework details in its HTTP User-Agent. The site isn't setup for .NET 4.5, etc. You get the idea. Plus, it's a pile of if statements and prayer and it's just horrible. Worse yet, it lives in a ZIP file on my hard drive and I drag it into SmartFTP to deploy. Yes, I know, this is all thick with irony.

此外,它开始断裂。 IE9 +在其HTTP User-Agent中不包含.NET Framework详细信息。 该网站未针对.NET 4.5等设置。您明白了。 另外,这是一堆if陈述和祈祷,真是太恐怖了。 更糟糕的是,它位于硬盘驱动器上的ZIP文件中,我将其拖到SmartFTP中进行部署。 是的,我知道,这真是讽刺。

I took and hour over lunch today to accomplish these basic goals:

我今天花了一个小时的午餐来实现这些基本目标:

  • Get this crap site into source control so others could help fix it

    将此 垃圾 站点置于源代码控制中,以便其他人可以帮助解决

  • Move the site to Azure and off my blog's server

    将网站移至Azure并移出我博客的服务器
  • Update the site's DNS

    更新站点的DNS
  • Setup continuous deployment with Git to Azure

    使用Git设置持续部署到Azure
  • Fix the .NET 4

    修复.NET 4
  • Maybe add .NET 4.5 detection

    也许添加.NET 4.5检测
  • Cleanse myself, possibly by reading Programming Pearls

    通过阅读Programming Pearls清洁自己

在Azure中制作网站(Making a Site in Azure)

I use the Azure Command Line Tools (get them with npm install azure). (I did an npm update azure --global to make sure I had the latest.)

我使用Azure命令行工具(通过npm install azure获取它们) 。 (我做了一个npm update azure --global来确保我拥有最新版本。)

I clone my Git Repository, create an Azure site, then make sure my Azure site is setup as a remote. (Soon the remote add will be made automatically when creating an Azure site from within a Git repro)

我克隆我的Git存储库,创建一个Azure站点,然后确保将我的Azure站点设置为远程站点。 (很快,从Git复制程序创建Azure站点时,将自动进行远程添加)

git clone https://github.com/shanselman/SmallestDotNet.git
azure create site SmallestDotNet

I copied my site in from elsewhere and

我从其他地方复制了我的网站,

git add .
git commit -m "Initial Commit"

Next, I'll associate my Azure site with my GitHub (or CodePlex) repo. I could also deploy from local files, but I like the idea of an auto-deploy since I'll guessing I'll be making lots of changes and this is one less thing to worry about.

接下来,我将Azure站点与GitHub(或CodePlex)存储库相关联。 我也可以从本地文件进行部署,但是我喜欢自动部署的想法,因为我想我会进行很多更改,因此这是一件值得担心的事情。

From the Deployment tab on the Azure Portal I'll use OAuth to authorize azure with GitHub.

在Azure门户的“部署”选项卡中,我将使用OAuth来授权GitHub上的Azure。

Associate a GitHub Repository

Then...

然后...

Authorize Windows Azure?

I'll confirm the repository I'm using:

我将确认我正在使用的存储库:

Setup Publishing and Select the Repository to Publish

This sets up a WebHook plugged into GitHub so it'll notify Azure when a push happens, Azure will deploy.

这将设置一个插入GitHub的WebHook,以便在发生推送时通知Azure,Azure将部署。

Now, I'll push my repository to origin.

现在,我将把存储库推入原点。

git push origin master 

Within a second or so of this push, the site automatically updates and is up and running at smallestdotnet.azurewebsites.net. I'll do a custom domain in a second.

在大约一秒钟的时间内,该站点会自动更新并在Minimumdotnet.azurewebsites.net上运行。 我将在一秒钟内做一个自定义域。

Yes, I should probably make a deployment branch. I could have two small Azure sites and then have each represent a deployment from a different branch in Git. Then I could git push staging and git push production.

是的,我可能应该进行部署分支。 我可以有两个小型Azure站点,然后每个站点代表来自Git中不同分支的部署。 然后我可以进行git push阶段和git push生产。

Animated Gif showing a Deployment slide into the queue

To move the domain name records from my own server to azure, I'll log into my DNSimple account (referral link for a free month!) and create a CNAME that points to my new site.

要将域名记录从我自己的服务器移到azure,我将登录到我的DNSimple帐户(一个免费月的引荐链接!)并创建一个指向我的新站点的CNAME。

Creating a CName and an A Record to point to Azure

Back in the Azure Management Portal - about 10 minutes later - I'll click Manage Domains and enter my new CName.

返回Azure管理门户-大约10分钟后-我将单击“管理域”并输入新的CName。

I'm also using an A record so read the instructions carefully.  After Azure verifies the CNAME, I return and add the A record. That way I can have not just www. but also the "naked" domain work as well.

我也在使用A记录,因此请仔细阅读说明。 Azure验证CNAME后,我返回并添加A记录。 这样,我不仅可以拥有www。 而且也可以使用“裸”域。

I visit the site, and boom. It's there. http://www.smallestdotnet.com/ is on Azure in less than a lunch hour. About 25 minutes, actually. Whew.

我访问该站点,并且繁荣。 在那。 http://www.smallestdotnet.com/在Azure上的使用时间不到一个小时。 大约25分钟。 ew。

Next, I have to fix the horrible code and bugs. Join me and issue a pull request.  ;)

接下来,我必须修复可怕的代码和错误。 和我一起发出拉动请求。 ;)

Thanks to Calin Balauru for his help with the code a few months back.

感谢Calin Balauru几个月前对代码的帮助。

Related Reading: ScottGu on Continuous Deployment in Azure with Git

相关阅读: ScottGu有关使用Git在Azure中进行持续部署

翻译自: https://www.hanselman.com/blog/moving-a-website-to-azure-while-adding-continuous-deployment-from-git

mac azure git

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值