-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove deprecated Azure SDK's from Calamari.CloudAccounts #1356
base: main
Are you sure you want to change the base?
Conversation
public static readonly AzureKnownEnvironment Global = new AzureKnownEnvironment("AzureGlobalCloud"); | ||
public static readonly AzureKnownEnvironment AzureChinaCloud = new AzureKnownEnvironment("AzureChinaCloud"); | ||
public static readonly AzureKnownEnvironment AzureUSGovernment = new AzureKnownEnvironment("AzureUSGovernment"); | ||
public static readonly AzureKnownEnvironment AzureGermanCloud = new AzureKnownEnvironment("AzureGermanCloud"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this was unused. The only one was Global
, but we only needed the string, so let's just use it.
source/Calamari.Azure/Kubernetes/Discovery/AzureKubernetesDiscoverer.cs
Outdated
Show resolved
Hide resolved
var token = !jwt.IsNullOrEmpty() | ||
? await new AzureOidcAccount(variables).Credentials(CancellationToken.None) | ||
: await new AzureServicePrincipalAccount(variables).Credentials(); | ||
var resourcesClient = new ResourceManagementClient(token, AuthHttpClientFactory.ProxyClientHandler()) | ||
{ | ||
SubscriptionId = subscriptionId, | ||
BaseUri = new Uri(resourceManagementEndpoint), | ||
}; | ||
resourcesClient.HttpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); | ||
resourcesClient.HttpClient.BaseAddress = new Uri(resourceManagementEndpoint); | ||
return resourcesClient; | ||
}; | ||
|
||
await CreateDeployment(createArmClient, resourceGroupName, deploymentName, deploymentMode, template, parameters); | ||
{ | ||
var account = AzureAccountFactory.Create(variables); | ||
var token = new TokenCredentials(await account.GetAuthorizationToken(log, CancellationToken.None)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consolidating around the AzureAccountFactory
and the new IAzureAccount.GetAuthorizationToken
method
public string ClientId { get; } | ||
public string TenantId { get; } | ||
public string Jwt { get; } | ||
public string AzureEnvironment { get; } | ||
public string ResourceManagementEndpointBaseUri { get; } | ||
public string ActiveDirectoryEndpointBaseUri { get; } | ||
|
||
internal static string GetDefaultScope(string environmentName) | ||
public async Task<string> GetAuthorizationToken(ILog log, CancellationToken cancellationToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this code was in the two extension method classes (one for each type), but changed to instance methods so they can be accessed through the IAzureAccount
2a80b23
to
d47d44f
Compare
d47d44f
to
4c8f8f8
Compare
Removes the use of
Microsoft.Rest
andMicrosoft.Azure.Management.Fluent
fromCalamari.CloudAccounts
as these are deprecated libraries.The main code changes is to move the logic for retrieving the access token on to the
IAzureAccount
implementations, rather than on extension methods