小编edt*_*eke的帖子

从 Azure 资源管理器模板中的资源组获取标签

从定义了名为 name 的标签的资源组tag1(通过门户完成),我在 Visual Studio 中拥有以下部署模板:

{
      "name": "appsettings",
      "type": "config",
      "apiVersion": "2015-08-01",
      "dependsOn": [
        "[resourceId('Microsoft.Web/sites', variables('websiteName'))]"
      ],
      "tags": {
        "displayName": "website AppSettings"
      },
      "properties": {
        "Setting1":  "[resourceGroup().tags.tag1]",
        "Setting2": "[parameters('param2')]"
      }
    }
Run Code Online (Sandbox Code Playgroud)

我收到这个错误:

...'语言表达式属性'tags'不存在,可用属性为'id、name、location、properties'...

但是使用https://resources.azure.com我可以看到资源组tag确实具有以下属性:

{
    "id": "/subscriptions/{someguid}/resourceGroups/resourceGroup1",
    "name": "resourceGroup1",
    "location": "brazilsouth",
    "tags": {
        "tag1": "test"
    },
    "properties": {
        "provisioningState": "Succeeded"
    }
}
Run Code Online (Sandbox Code Playgroud)

有没有办法获取部署模板中的资源组标签?

更新

正如 @juvchan 指出的,标签必须存在,否则会发生此错误。我创建了标签,但是从 VisualStudio 部署模板时,标签被删除,从门户部署时,标签被保留。这导致了不同的问题。

原因是 Visual Studio 项目有一个包含以下行的 PowerShell 脚本:

#Create or update the resource group using the …
Run Code Online (Sandbox Code Playgroud)

azure azure-resource-manager azure-rm-template azure-resource-group

5
推荐指数
1
解决办法
3632
查看次数

像浏览器一样组合完整的URL和虚拟URL

我有一个完整的URL,如:.A: http://www.domain.com/aaa/bbb/ccc/ddd/eee.ext

我有一个相对的URL,如: B: ../../fff.ext

我正在寻找.NET C#中最简单的方法来组合这两个URL并得到: C: http://www.domain.com/aaa/bbb/fff.ext

这与浏览器的作用类似:您正在浏览URL A,然后,页面的HTML具有B的超链接,结果URL为C.

c# uri relative-path

3
推荐指数
1
解决办法
976
查看次数