-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The apiVersion x was not found for the resource type #714
Comments
@andre-lx we recently did some changes that hopefully improved the API Version checking for case. Could kindly:
Also, you should be able to adjust the parameters for this particular test with # Run the api versions test, but warn if the api version is more than 30 days old (you could just as easily say 3000)
Test-AzTemplate -TemplatePath .\MyTemplate.json -Test "APIVersions-Should-Be-Recent" -TestParameter @{
NumberOfDays = 30
} |
Hello. About the version, we always use the master version in our pipelines. For the following template, I can conclude that:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"metadata": {
"description": "The location of the platform."
},
"type": "string"
}
},
"variables": {
},
"resources": [
//
// Test 1 - userAssignedIdentities API Version Uppercase amd Lowercase
// this gives a warning
{
"type": "Microsoft.ManagedIdentity/userAssignedIdentities",
"apiVersion": "2022-01-31-preview",
"name": "test",
"location": "[parameters('location')]"
},
{
"type": "Microsoft.ContainerRegistry/registries",
"apiVersion": "2022-02-01-PREVIEW",
"name": "[variables('acrName')]",
"location": "[parameters('location')]"
},
// this pass
{
"type": "Microsoft.ManagedIdentity/userAssignedIdentities",
"apiVersion": "2022-01-31-PREVIEW",
"name": "test",
"location": "[parameters('location')]"
},
{
"type": "Microsoft.ContainerRegistry/registries",
"apiVersion": "2022-02-01-preview",
"name": "[variables('acrName')]",
"location": "[parameters('location')]"
},
//
// Test 2 - most recent versions
// most recent
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2022-07-01",
"name": "[variables('vnetName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"172.16.0.0/18"
]
}
},
"resources": []
},
// to update
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2021-08-01",
"name": "[variables('vnetName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"172.16.0.0/18"
]
}
},
"resources": []
},
//
// Test 3 - privateDnsZoneGroups
// apiVersion 2021-08-01 was not found for the resource type
{
"type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups",
"apiVersion": "2021-08-01",
"name": "[concat('test','/test')]",
"location": "[parameters('location')]",
"properties": {
"privateDnsZoneConfigs": [
{
"name": "config",
"properties": {
"privateDnsZoneId": "[resourceId('Microsoft.Network/privateDnsZones', 'test')]"
}
}
]
}
},
//
// Test 4 - Microsoft.Authorization
// apiVersion 2022-01-01-preview was not found for the resource type: Microsoft.Authorization
{
"type": "Microsoft.Storage/storageAccounts/providers/roleAssignments",
"apiVersion": "2022-01-01-preview",
"name": "[concat(variables('storageAccountName'), '/Microsoft.Authorization/', variables('bootstrapRoleAssignmentStorageAdmin'))]",
"properties": {
"roleDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'test')).principalId]",
"scope": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"principalType": "ServicePrincipal"
}
}
],
"outputs": {
}
} Running:
I get the following result:
|
I'm not able to repro with 0.20 - @andre-lx - this has been merge, feel free to reopen if you're still seeing it. |
Hi @bmoore-msft I confirm that the last version fixes most of the issues. The only one I still see is the: {
"type": "Microsoft.Storage/storageAccounts/providers/roleAssignments",
"apiVersion": "2022-01-01-preview",
"name": "[concat(variables('storageAccountName'), '/Microsoft.Authorization/', variables('bootstrapRoleAssignmentStorageAdmin'))]",
"properties": {
"roleDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'test')).principalId]",
"scope": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"principalType": "ServicePrincipal"
}
} Thanks, André |
Ah - got it, I glossed over that one as "accurate"... We do have issues with extension resources when you overload the type... however the pattern is antiquated, so we decided not to fix it. The recommended way to author that snippet would be to use the scope property: {
"scope": "[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2022-01-01-preview",
"name": "[variables('bootstrapRoleAssignmentStorageAdmin')]",
"properties": { ... }
} |
Sorry for the late reply. I can confirm that your solution works as expected. Thanks |
Hi.
We are facing the following warnings in our validation, but the template works without any problem:
For the type
privateDnsZoneGroups
andMicrosoft.Authorization
I cannot find it in thearm-ttk/cache/AllAzureResources.cache.json
file.For the type
userAssignedIdentities
I can see the version with"2022-01-31-PREVIEW",
, so maybe is because of the caps lock PREVIEW word?Also, the template looks like is not warning me about recent versions, for example:
I did not receive the warning about the new versions present in the file:
Only the
2 years old (730 days)
warning. It is possible to activate this test in order to use/be warned always about the latest version?Thanks, André
The text was updated successfully, but these errors were encountered: