azureazure-resource-managerazure-bicepazure-postgresql

How to find out which API to use in ARM Template to provision Postgresql flexible server


I created a bicep script to provision out a Postgresql Flexible server. I then build the script and output an ARM template to use in Azure Portal.

The deployment fails with the following errors.

No registered resource provider found for location 'eastus' and API version '2024-03-01-preview' for type 'flexibleServers

Then it goes on to list out the supported APis and regions.

Is there a way to find out the latest API for a specific region and a particular resource supports before trying to deploy?

Update

I attempted to create the resource from Azure portal so I can then export the template to see which API version it is using, but i am getting a Subscription 'XYZ' is not allowed to provision in region 'EastUS'. I will try to provision in another region.

Thanks


Solution

  • No registered resource provider found for location 'eastus' and API version '2024-03-01-preview'
    

    The error you encountered above is due to an invalid API version in the Bicep code.

    enter image description here

    You can check the supported API versions for flexibleServers.

    az provider show --namespace Microsoft.DBforPostgreSQL --query "resourceTypes[?resourceType=='flexibleServers'].apiVersions"
    

    enter image description here

    Here is the updated Bicep code to create Flexible Servers using the latest API version, 2024-08-01.

    param administratorLogin string = 'Venkat'
    
    @secure()
    param administratorLoginPassword string = 'Welcome@123$'
    param location string = 'eastus'
    param serverName string = 'sample-server-001' // Changed to a valid server name
    param serverEdition string = 'GeneralPurpose'
    param skuSizeGB int = 128
    param dbInstanceType string = 'Standard_D4ds_v4'
    param haMode string = 'ZoneRedundant'
    param availabilityZone string = '1'
    param version string = '12'
    
    resource serverName_resource 'Microsoft.DBforPostgreSQL/flexibleServers@2024-08-01' = {
      name: serverName
      location: location
      sku: {
        name: dbInstanceType
        tier: serverEdition
      }
      properties: {
        version: version
        administratorLogin: administratorLogin
        administratorLoginPassword: administratorLoginPassword
        network: {
          publicNetworkAccess: 'Enabled' 
        }
        highAvailability: {
          mode: haMode
        }
        storage: {
          storageSizeGB: skuSizeGB
        }
        backup: {
          backupRetentionDays: 7
          geoRedundantBackup: 'Disabled'
        }
        availabilityZone: availabilityZone
      }
    }
    

    Output:

    enter image description here