我导出了一个azure资源组,其中包含许多服务,例如apimanagement、webapp、databae、虚拟网络等 现在我想将此模板部署到其他资源组,但出现以下错误
@secure()
param apis_uat_policy_detail_path string
@secure()
param apis_uat_policy_detail_v1_path string
@secure()
param users_1_lastName string
param sites_fapp_eus_fsps_u_01_name string = 'fapp-eus-fsps-u-01'
param vaults_kv_eus_fsps_u_01_name string = 'kv-eus-fsps-u-01'
resource service_apim_eus_fsps_u_01_name_resource 'Microsoft.ApiManagement/service@2023-09-01-preview' = {
name: service_apim_eus_fsps_u_01_name
location: 'East US'
sku: {
name: 'Basic'
capacity: 1
}
identity: {
type: 'SystemAssigned'
}
properties: {
publisherEmail: '[email protected]'
publisherName: 'FS-UAT'
notificationSenderEmail: '[email protected]'
hostnameConfigurations: [
{
type: 'Proxy'
hostName: '${service_apim_eus_fsps_u_01_name}.azure-api.net'
negotiateClientCertificate: false
defaultSslBinding: false
certificateSource: 'BuiltIn'
}
{
type: 'Proxy'
hostName: 'fspsapi-fsps-uat.xceedance.com'
negotiateClientCertificate: false
certificate: {
expiry: '2025-04-19T16:34:55+00:00'
thumbprint: 'B199FC420816C01B7FB532C61'
subject: 'CN=*.aaaa.com'
}
defaultSslBinding: true
certificateSource: 'Custom'
}
]
customProperties: {
'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10': 'False' 'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_GCM_SHA256': 'false'
}
virtualNetworkType: 'None'
disableGateway: false
natGatewayState: 'Unsupported'
apiVersionConstraint: {}
publicNetworkAccess: 'Enabled'
privateEndpointConnections: [
{
id: service_apim_eus_u_01_name_pe_apim_eus_fsps_u_0.id #here is the error
name: 'pe-apim-eus-fsps-u-0'
type: 'Microsoft.ApiManagement/service/privateEndpointConnections'
properties: {
privateEndpoint: {}
privateLinkServiceConnectionState: {
status: 'Approved'
}
}
}
]
legacyPortalStatus: 'Disabled'
developerPortalStatus: 'Enabled'
}
}
这是代码的一小部分,通过模板得到这个错误。
错误 BCP080:部署时,表达式涉及 azure 中的循环 Bicep 文件:
上述消息是 MS Doc 中给出的 bicep 错误代码之一,通常在将模板从 ARM Json 反编译为 Bicep 时发生,因为模板结构彼此不同。
当二头肌编译器发现参数或资源指向自身时,就会发生此错误。这意味着资源对资源具有循环依赖关系,并且它们在部署时依赖于当前资源。
注意:我在这里研究过类似的问题。参考 SO.
感谢@Thomas 指出了我想到的方向。问题出在代码中的
privateendpointconnections
块。
这里的
id
正在APIM实例和私有端点之间创建连续依赖关系。为了解决冲突,请删除该块和一个单独的资源提供程序,以便与 Microsoft.ApiManagement/service/privateEndpointConnections
建立私有端点连接,如下所示。
resource privateEndpointConnection 'Microsoft.ApiManagement/service/privateEndpointConnections@2023-09-01-preview' = {
name: 'lat-eus-fsps-u-0'
parent: service_apim_eus_fsps_u_01_name_resource
properties: {
privateLinkServiceConnectionState: {
status: 'Approved'
}
}
}