查询Azure Web Apps版本号 [英] Querying Azure Web Apps Version Number

查看:57
本文介绍了查询Azure Web Apps版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用VSTS部署到Azure Web App插槽.我们希望网站能够了解其内部版本号,以进行版本控制.

We are deploying to Azure Web App slots using VSTS. We want a way for the website to know its build number for versioning purpose.

我们考虑过在发布过程中将VSTS构建设置为环境变量,因为Azure Web App网站可以访问该环境变量.

We thought of setting the VSTS build as an environment variable during the release process as the Azure Web App website has access to the environment variable.

我们还注意到,VSTS在向VSTS发布之前警告您,您将再次发布相同的内部版本,因​​此VSTS必须有一种方法为此查询Azure Web App.

And we also noticed that VSTS warns you before releasing to VSTS that you are releasing the same build again, so there must be a way that VSTS is querying Azure Web App for this.

  • 是否有从网站内部了解构建版本的标准方法?
  • 如果没有,除了在发行过程中具有环境变量之外,还有没有更好的查询版本号的方法?

推荐答案

如果您只想在Web应用程序中使用内部版本号(例如,在页面中显示),则可以将内部版本号存储在配置文件中,例如作为web.config,appsettings.json,然后读取代码中的值.

If you just want to use the build number in you web app (e.g. display in a page), you can store the build number in the configuration file, such as web.config, appsettings.json, then read the value in your code.

要将内部版本号存储在配置文件中,可以使用替换令牌来完成.任务之前,Visual Studio会在构建定义中构建任务.

To store the build number in configuration file, you can do it by using Replace Token task before visual studio build task in build definition.

如果要在其他任务中使用内部版本号,例如将当前内部版本号与当前应用程序服务内部版本号进行比较,则可以将内部版本号存储在azure应用程序服务的AppSettings中.简单的工作流程:

If you want to use the build number in additional task, for example compare current build number with the current app service build number, you can store the build number in AppSettings of azure app service. Simple workflow:

  1. 添加azure PowerShell任务以调用Get-AzureRMWebAppSlot以获取AppSettings并与当前内部版本号进行比较
  2. 如果它们不同,则可以通过Azure WebApp部署任务将程序包部署为天蓝色.
  3. 添加azure PowerShell任务以调用Set-AzureRMWebAppSlot以更新AppSettings.

有一个博客:顺便说一句:您可以通过 Build.BuildNumber获取当前的内部版本号. 中的变量.

BTW: You can get the current build number through Build.BuildNumber variable in Build/Release.

这篇关于查询Azure Web Apps版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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