Reputation: 41
I am looking for a programmatic way to get available Kubernetes versions in a given Azure region using .NET SDKs. Something similar to the following Azure CLI command:
az aks get-versions --location eastus --output table
I am currently using Microsoft.Azure.Management.ContainerService.Fluent.ContainerServiceManagementClient
class to create clusters and get details of existing cluster. But that does not seem to expose any way to get available Kubernetes versions in a region.
Upvotes: 1
Views: 2869
Reputation: 41
I ended up using Microsoft.Azure.Management.Fluent
package and its IAzure
interface. The code looks something like this:
var azure = Azure
.Configure()
.Authenticate(azureCredentials)
.WithSubscription(subscriptionId);
var kubernetesVersions = await azure
.KubernetesClusters
.ListKubernetesVersionsAsync(region, cancellationToken);
The peculiarity of this call is that it returns much more results than az aks get-versions
. So I had to find latest patch version of a specific Kubernetes version (1.16.x
) that I was looking for. But that is necessary in any case.
Upvotes: 0
Reputation: 222682
You can use REST API
public static async Task<string> GetAksVersions(string token, string subscriptionId, string location)
{
var aksVersionsUri = $"https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.ContainerService/locations/{location}/orchestrators?api-version=2017-09-30&resource-type=managedClusters";
var json = await ExecuteGetOnAzureApi(aksVersionsUri, token);
return json;
}
Upvotes: 1