如何通过二头肌将日志分析工作区添加到现有的ampls

问题描述 投票:0回答:1

背景

我们有一个中心辐射型拓扑。在中心有一个放大器,它已经连接了一个日志分析工作区,该工作区也存在于中心中。这有效。所有资源都是通过二头肌添加的。

新的日志分析工作区

在新的分支中,我添加了一个日志分析工作区。正如文档所说,您应该将其添加到现有的amps中。

二头肌

我创建了一个新的二头肌模块,应该可以做到这一点

resource law 'Microsoft.OperationalInsights/workspaces@2022-10-01' existing = {
  scope: resourceGroup(lawSubId, lawRg)
  name: lawName
}

resource ampls 'microsoft.insights/privatelinkscopes@2021-07-01-preview' existing = {
  scope: resourceGroup(amplsSubscriptionId, amplsRg)
  name: amplsName
}

// deploy ampls scoped resources - misschien moet dit gewoon bij de law deployment?
resource amplsScope 'microsoft.insights/privatelinkscopes/scopedresources@2021-07-01-preview' = {
  parent: ampls
  name: amplsScopeName
  properties: {
    linkedResourceId: law.id
  }
}

因此法律和 amps 资源已经存在,我想添加一个新范围,以便将 amps 和法律连接起来。

错误

通过上述设置,我收到以下错误:

Error BCP165: A resource's computed scope must match that of the Bicep file for it to be deployable. This resource's scope is computed from the "scope" property value assigned to ancestor resource "ampls". You must use modules to deploy resources to a different scope.

但是当我尝试移动现有的 ampls 资源以便 amplsScope 现在是模块中的部署时,我收到错误,父类型是字符串而不是“privatelinkscopes”。

请求

有谁知道如何在二头肌中实现这一目标?由于我通过 Azure DevOps 管道部署它,因此我也很乐意使用 Azure CLI 示例,或者如果没有其他选择,则使用 powershell。

如果有任何信息缺失,请告诉我。

azure azure-resource-manager azure-cli azure-bicep azure-log-analytics-workspace
1个回答
0
投票

您的部署范围需要与您正在部署的资源范围相匹配:您无法在模块中指定amps的范围

resource law 'Microsoft.OperationalInsights/workspaces@2022-10-01' existing = {
  scope: resourceGroup(lawSubId, lawRg)
  name: lawName
}

resource ampls 'microsoft.insights/privatelinkscopes@2021-07-01-preview' existing = {
  name: amplsName
}

// deploy ampls scoped resources - misschien moet dit gewoon bij de law deployment?
resource amplsScope 'microsoft.insights/privatelinkscopes/scopedresources@2021-07-01-preview' = {
  parent: ampls
  name: amplsScopeName
  properties: {
    linkedResourceId: law.id
  }
}

然后你可以像这样调用你的模块:

az deployment group create --resource-group <ampls-rg>

如果此模块是更大部署的一部分,您可以在调用该模块时指定范围:

// main.bicep

module approvePrivateEndpoint 'modules/ampls-scoped-resource.bicep' = {
  name: 'ampls-scoped-resource'
  scope: resourceGroup(amplsSubscriptionId, amplsRg)
  params: {
    amplsName: ''
    amplsScopeName: ''
    lawName: ''
    lawRg: ''
    lawSubId: ''
  }
}

© www.soinside.com 2019 - 2024. All rights reserved.