Skip to content

Commit

Permalink
Fixed getting credentials from config
Browse files Browse the repository at this point in the history
  • Loading branch information
1101-1 committed Oct 12, 2023
1 parent 4dfa355 commit 726b988
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions plugins/azure/resoto_plugin_azure/resource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from azure.core.utils import CaseInsensitiveDict

from resoto_plugin_azure.azure_client import AzureApiSpec, AzureClient
from resoto_plugin_azure.config import AzureCredentials, AzureAccountConfig
from resoto_plugin_azure.config import AzureConfig, AzureCredentials
from resotolib.baseresources import BaseResource, Cloud, EdgeType, BaseAccount, BaseRegion, ModelReference
from resotolib.core.actions import CoreFeedback
from resotolib.graph import Graph, EdgeKey
Expand All @@ -23,8 +23,11 @@

def get_client(subscription_id: str) -> AzureClient:
config = current_config()
azure_config = cast(AzureAccountConfig, config.azure)
return AzureClient.create(credential=azure_config.credentials(), subscription_id=subscription_id)
azure_config = cast(AzureConfig, config.azure)
# Taking credentials from the config if access through the environment cannot be provided
if azure_config.accounts and (account := azure_config.accounts[subscription_id]):
credential = account.credentials()
return AzureClient.create(credential=credential, subscription_id=subscription_id)


T = TypeVar("T")
Expand Down

0 comments on commit 726b988

Please sign in to comment.