Skip to content

Commit

Permalink
Merge pull request #24056 from hashicorp/auth/use-azure-cli-caching
Browse files Browse the repository at this point in the history
bugfix: resolve issue with no-deadline context when listing RPs
  • Loading branch information
manicminer authored Nov 30, 2023
2 parents 828f8cf + da00dc3 commit 01fb62c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions internal/clients/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"fmt"
"log"
"time"

"github.com/hashicorp/go-azure-helpers/authentication"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
Expand Down Expand Up @@ -167,8 +168,11 @@ func Build(ctx context.Context, builder ClientBuilder) (*Client, error) {
if features.EnhancedValidationEnabled() {
subscriptionId := commonids.NewSubscriptionID(client.Account.SubscriptionId)

location.CacheSupportedLocations(ctx, *resourceManagerEndpoint)
if err := resourceproviders.CacheSupportedProviders(ctx, client.Resource.ResourceProvidersClient, subscriptionId); err != nil {
ctx2, cancel := context.WithTimeout(ctx, 10*time.Minute)
defer cancel()

location.CacheSupportedLocations(ctx2, *resourceManagerEndpoint)
if err := resourceproviders.CacheSupportedProviders(ctx2, client.Resource.ResourceProvidersClient, subscriptionId); err != nil {
log.Printf("[DEBUG] error retrieving providers: %s. Enhanced validation will be unavailable", err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions website/docs/guides/azure_cli.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ We recommend using either a Service Principal or Managed Service Identity when r

## Logging into the Azure CLI

~> **Note**: If you're using the **China**, **German** or **Government** Azure Clouds - you'll need to first configure the Azure CLI to work with that Cloud. You can do this by running:
~> **Note**: If you're using the **China** or **Government** Azure Clouds - you'll need to first configure the Azure CLI to work with that Cloud. You can do this by running:

```shell
az cloud set --name AzureChinaCloud|AzureGermanCloud|AzureUSGovernment
az cloud set --name AzureChinaCloud|AzureUSGovernment
```

---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Once logged in as the Service Principal - we should be able to list the VM sizes
az vm list-sizes --location westus
```

~> **Note**: If you're using the **China**, **German** or **Government** Azure Clouds - you will need to switch `westus` out for another region. You can find which regions are available by running:
~> **Note**: If you're using the **China** or **Government** Azure Clouds - you will need to switch `westus` out for another region. You can find which regions are available by running:

```shell
az account list-locations
Expand Down

0 comments on commit 01fb62c

Please sign in to comment.