Open slavizh opened 4 months ago
Tagging as "intermediate language" because there's currently no way to represent any
in ARM's parameter typing system, and that would need to be in place before any
could be added to Bicep. The closest you can get right now is object
(which corresponds to { *: any }
) or array
(which corresponds to any[]
).
any is flagged as invalid type if you add it to parameter
Another example coming from the same resource:
It makes it hard to create schemas for these. Cannot be overcome even with any() put in the Bicep parameters file for the value.
Additionally to the first example there is a Float type that also uses any
I could use this too. I am trying to setup some user defined types for a module I'm creating to setup parameter types that match the expected values for an apim operation templateParamteres, responses, etc:
but there is no way for met to define:
@export()
type ParameterExampleContract = {
@description('Long description for the example')
description: string?
@description('A URL that points to the literal example')
externalValue: string?
@description('Short Description for the example')
summary: string?
@description('Examle value. May be a primative value, or an object')
value: any
}
Although what would be cool is if I could just import ParameterContract[]
from Microsoft.ApiManagement/service/apis/operations
.
So I could do something like:
import {ParameterContract} from 'Microsoft.ApiManagement/service/apis/operations'
param operationTemplateParameters: ParameterContract[]
Then I don't have to try and recreate these contracts in my bicep files and can reuse the contracts already defined by the resource definitions. (Maybe I'll make a feature request for this)
@jefedeltodos You could try the experimental resource-derived types feature. This would require a bicepconfig.json
file like the following:
{
"experimentalFeaturesEnabled": {
"resourceDerivedTypes": true
}
}
With that in place, you could define your parameter as the following:
param operationTemplateParameters resource<'Microsoft.ApiManagement/service/apis/operations@2022-08-01'>.properties.templateParameters
Another example from policy assignments
This time I cannot make workaround by using discriminator type as I would have to make breaking change to existing template.
We are also running into this, not sure how to implement user-defined types for resources such as an Azure Policy assignment that has properties that can accept arbitrary types. Having the "any" type available would make this scenario a lot easier to deal with.
Running into this issue as well, policy assignments are the most egregious ones.
another example of any:
Is your feature request related to a problem? Please describe. This API seems to have type of any. Should such type be available in user defined types?![image](https://github.com/Azure/bicep/assets/11890856/f6e57df9-1e5e-41f1-97c4-908b2166ebaa)
Describe the solution you'd like Should such type be available in user defined types?