'Get latest API version for Azure Workspace SQL Pool using powershell

I've tried multiple options in powershell like Get-AzSynapseWorkspace but I cannot find anywhere the latest API version for Synapse Analytics.

I'm calling a REST API using the below code but it was failing due to the api version of the Microsoft.Synapse/workspaces/ .. After searching in the web I found a couple of api versions, I added one of those to a variable and it worked but it is an old date which means they might remove it one day so I need to know in the Azure portal or trough a powershell command how to pull the latest one so is not a static value assigned to a variable

"https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.Synapse/workspaces/$sqlServerName/sqlPools/$SynapseSqlPoolName"+"?api-version=$apiversion" 


Solution 1:[1]

You can use PowerShell to check which API versions are available.

$workspaces = (Get-AzResourceProvider -ProviderNamespace Microsoft.Synapse).resourcetypes | ? resourceTypeName -eq 'workspaces'

 $workspaces.ApiVersions
2021-06-01-preview
2021-06-01
2021-05-01
2021-04-01-preview
2021-03-01
2020-12-01
2019-06-01-preview

This works for all resources by chancing the providerNameSpace

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BrettMiller