在Azure功能中访问VSTS Build Server版本 [英] Accessing VSTS Build Server Version in Azure Function

查看:62
本文介绍了在Azure功能中访问VSTS Build Server版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Azure函数中获取VSTS内部版本号?我需要在Httptrigger端点上显示构建版本.

Is it possible to get the VSTS build number in Azure functions? I need to display the build version on an Httptrigger endpoint.

推荐答案

"local.settings.json"文件由于以下已知问题而无法使用:

"local.settings.json" file does not work due to a known issue here: Application settings not available from local.settings.json in Azure, but available locally in Visual Studio.

要获得所需的功能,可以在内部版本定义中添加"Azure PowerShell脚本"任务,以读取VSTS内部版本号并通过

To achieve the feature you want, you can add an "Azure PowerShell Script" task in your build definition to read the VSTS build number and update the Azure Webapp Appsettings via Set-AzureRmWebApp command. And then you can read the settings via code:

ConfigurationManager.AppSettings["VSTSBuildVersion"]

PowerShell脚本供您参考:

The PowerShell Script for your reference:

$app = Get-AzureRmWebApp -ResourceGroupName "ResourceGroupName" -Name "AzureFunctionAppName"
$appSettings = $app.SiteConfig.AppSettings
$newSettings = @{}

ForEach ($key in $appSettings)
{
    $newSettings[$key.Name] = $key.Value
}

$newSettings['VSTSBuildVersion'] = $env:BUILD_BUILDNUMBER

Set-AzureRmWebApp -ResourceGroupName "ResourceGroupName" -Name "AzureFunctionAppName" -AppSettings $newSettings

这篇关于在Azure功能中访问VSTS Build Server版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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