create azure StorageAccount with minTLS 1.2
@@ -5,7 +5,7 @@ import (
"log"
"net/url"
- "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-06-01/storage"
+ "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
"github.com/Azure/azure-storage-blob-go/azblob"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/adal"
@@ -38,21 +38,9 @@ func (r *Reconciler) CreateStorageAccount(accountName, accountGroupName string)
var s storage.Account
storageAccountsClient := r.getStorageAccountsClient()
- result, err := storageAccountsClient.CheckNameAvailability(
- r.Ctx,
- storage.AccountCheckNameAvailabilityParameters{
- Name: to.StringPtr(accountName),
- Type: to.StringPtr("Microsoft.Storage/storageAccounts"),
- })
- if err != nil {
- return s, fmt.Errorf("storage account check-name-availability failed: %+v", err)
- }
-
- if !*result.NameAvailable {
- return s, fmt.Errorf(
- "storage account name [%s] not available: %v\nserver message: %v",
- accountName, err, *result.Message)
- }
+ // we used to call storage.AccountCheckNameAvailabilityParameters here to make sure the name is available
+ // removed it because when using a newer API version (2019-06-01), this call produced some irrelevant errors sometimes
+ // if the name is not available, CreateStorageAccount will return an error, and a different name will be used next time
enableHTTPSTrafficOnly := true
future, err := storageAccountsClient.Create(
@@ -64,7 +52,10 @@ func (r *Reconciler) CreateStorageAccount(accountName, accountGroupName string)
Name: storage.StandardLRS},
Kind: storage.Storage,
Location: to.StringPtr(r.AzureContainerCreds.StringData["azure_region"]),
- AccountPropertiesCreateParameters: &storage.AccountPropertiesCreateParameters{EnableHTTPSTrafficOnly: &enableHTTPSTrafficOnly},
+ AccountPropertiesCreateParameters: &storage.AccountPropertiesCreateParameters{
+ EnableHTTPSTrafficOnly: &enableHTTPSTrafficOnly,
+ MinimumTLSVersion: storage.TLS12,
+ },
})
if err != nil {
@@ -82,7 +73,7 @@ func (r *Reconciler) CreateStorageAccount(accountName, accountGroupName string)
// GetStorageAccount gets details on the specified storage account
func (r *Reconciler) GetStorageAccount(accountName, accountGroupName string) (storage.Account, error) {
storageAccountsClient := r.getStorageAccountsClient()
- return storageAccountsClient.GetProperties(r.Ctx, accountGroupName, accountName)
+ return storageAccountsClient.GetProperties(r.Ctx, accountGroupName, accountName, storage.AccountExpandBlobRestoreStatus)
}
// DeleteStorageAccount deletes an existing storate account
@@ -107,7 +98,7 @@ func (r *Reconciler) CheckAccountNameAvailability(accountName string) (storage.C
// GetAccountKeys gets the storage account keys
func (r *Reconciler) GetAccountKeys(accountName, accountGroupName string) (storage.AccountListKeysResult, error) {
accountsClient := r.getStorageAccountsClient()
- return accountsClient.ListKeys(r.Ctx, accountGroupName, accountName)
+ return accountsClient.ListKeys(r.Ctx, accountGroupName, accountName, storage.Kerb)
}
func (r *Reconciler) getContainerURL(accountName, accountGroupName, containerName string) azblob.ContainerURL {
