Skip to content

Commit

Permalink
Merge pull request #159 from perfectsense/feature/cli-credentials
Browse files Browse the repository at this point in the history
Use azure cli credentials if client and key are not configured
  • Loading branch information
harjain99 authored Nov 11, 2024
2 parents 6e3f571 + 1606232 commit 4f8fa55
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/gyro/azure/AzureCredentials.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.azure.core.http.okhttp.OkHttpAsyncHttpClientBuilder;
import com.azure.core.management.AzureEnvironment;
import com.azure.core.management.profile.AzureProfile;
import com.azure.identity.AzureCliCredentialBuilder;
import com.azure.identity.ClientSecretCredentialBuilder;
import com.azure.resourcemanager.AzureResourceManager;
import com.azure.resourcemanager.communication.CommunicationManager;
Expand Down Expand Up @@ -132,6 +133,10 @@ public <T> T createClient(Class<T> clientClass) {
}

public TokenCredential getTokenCredential(String tenant, String client, String key) {
if (tenant == null || client == null || key == null) {
return new AzureCliCredentialBuilder().build();
}

return new ClientSecretCredentialBuilder()
.clientId(ObjectUtils.to(String.class, client))
.clientSecret(ObjectUtils.to(String.class, key))
Expand Down

0 comments on commit 4f8fa55

Please sign in to comment.