NamedValue not getting replaced in Connection String for APIM Bicep #15904
Replies: 5 comments 1 reply
-
I think it might be due to how the named-value is referenced. Try removing the |
Beta Was this translation helpful? Give feedback.
-
Yes, I tried that first, it fails with validation error |
Beta Was this translation helpful? Give feedback.
-
I think you can't use connection string with api-management. I think it only supports instrumentationKey like this: resource applicationInsightsLogger 'Microsoft.ApiManagement/service/loggers@2020-12-01' = {
parent: apiManagement
name: applicationInsightsName
properties: {
loggerType: 'applicationInsights'
credentials: {
instrumentationKey: '{{${applicationInsightsNamedValue.properties.displayName}}}'
}
}
} I'm using this widely and it works like a charm the named value can be a KV reference, it doesn't really matter as the API-M fetches the value into it's store and then it's used in policies or in above. |
Beta Was this translation helpful? Give feedback.
-
+1 I am also facing a similar issue. If I deploy like:
APIM will generate a namedValue with a guid containing my connection string. If I redeploy the template, it will generate another (new) namedValue. This sucks. If I try with my own named value defined (that contains the connection string):
It will deploy the logger but the Is this a resource provider issue? |
Beta Was this translation helpful? Give feedback.
-
I believe you are expected to put the instrumentation key in full because if you try to use variable substitution using the rest API, you get the following error:
This is triggered by the brackets used by variable substitution. However, variable substitution is supported for the identityClientId field (automatically generated). Also, I see that you are using AAD authentication to the application insights resource so you could simply put the connection string in plain text and disable local authentication on the application insights resource. Once local authentication is disabled, the connection string loses a lot of sensibility (as long as you don't reactivate it of course). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Bicep version
v0.31.92
Describe the bug
I have a namedValue defined for APIM that in turn refers it's value from a key vault secret, but when I try to use that namedValue in the connection string for Application Insights logger, it fails with this error.
"Validation failed for logger-id 'appi_logger_smi'. Exception Received 'Invalid instrumentation key for Application Insights Logger"
To Reproduce
Define a NamedValue like this
then try to access it in the logger.
Additional context
Add any other context about the problem here.
Beta Was this translation helpful? Give feedback.
All reactions