Skip to content

Commit bdbe2bc

Browse files
committed
Change Disk Client API Version for Azure Stack
The standard 2020-06-01 API Version is not supported for disk operations in Azure Stack, so change to the compatible 2018-06-01 profile.
1 parent 36ca4a4 commit bdbe2bc

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

azure/defaults.go

+4
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ const (
116116
// StackAPIVersion is the API version profile to set for ARM clients. See:
117117
// https://learn.microsoft.com/en-us/azure-stack/user/azure-stack-profiles-azure-resource-manager-versions?view=azs-2408#overview-of-the-2020-09-01-hybrid-profile
118118
StackAPIVersionProfile = "2020-06-01"
119+
120+
// StackDiskAPIVersionProfile is the API Version to set for the disk client.
121+
// API Version Profile "2020-06-01" is not supported for disks.
122+
StackDiskAPIVersionProfile = "2018-06-01"
119123
)
120124

121125
var (

azure/services/disks/client.go

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package disks
1818

1919
import (
2020
"context"
21+
"strings"
2122
"time"
2223

2324
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
@@ -38,6 +39,9 @@ type azureClient struct {
3839
// newClient creates a new disks client from an authorizer.
3940
func newClient(auth azure.Authorizer, apiCallTimeout time.Duration) (*azureClient, error) {
4041
opts, err := azure.ARMClientOptions(auth.CloudEnvironment(), auth.BaseURI())
42+
if strings.EqualFold(auth.CloudEnvironment(), azure.StackCloudName) {
43+
opts.APIVersion = azure.StackDiskAPIVersionProfile
44+
}
4145
if err != nil {
4246
return nil, errors.Wrap(err, "failed to create disks client options")
4347
}

0 commit comments

Comments
 (0)