Class AzureOperations
- Namespace
- Ando.Operations
- Assembly
- ando.dll
Provides Azure CLI authentication and account management operations. Methods register steps in the workflow rather than executing immediately.
public class AzureOperations : OperationsBase
- Inheritance
-
AzureOperations
- Inherited Members
Constructors
AzureOperations(StepRegistry, IBuildLogger, Func<ICommandExecutor>)
Provides Azure CLI authentication and account management operations. Methods register steps in the workflow rather than executing immediately.
public AzureOperations(StepRegistry registry, IBuildLogger logger, Func<ICommandExecutor> executorFactory)
Parameters
registryStepRegistryloggerIBuildLoggerexecutorFactoryFunc<ICommandExecutor>
Methods
CreateResourceGroup(string, string)
Registers a step to create a resource group if it doesn't exist.
public void CreateResourceGroup(string name, string location)
Parameters
EnsureAuthenticated()
Ensures Azure authentication is available, using the best available method:
- If service principal env vars are set (AZURE_CLIENT_ID, etc.), uses service principal login
- If Azure CLI is available and already logged in, uses existing session
- If Azure CLI is available but not logged in, runs interactive
az login - If Azure CLI is not installed, prompts user to install it
public void EnsureAuthenticated()
EnsureLoggedIn()
Registers a step to verify the user is logged in to Azure. Fails the build if not authenticated.
public void EnsureLoggedIn()
GetAzureCliInstallInstructions()
Gets OS-specific installation instructions for Azure CLI.
public static string GetAzureCliInstallInstructions()
Returns
- string
Installation command or URL for the current platform.
IsAzureCliAvailable()
Checks if Azure CLI is installed and available on the system.
public static bool IsAzureCliAvailable()
Returns
- bool
True if Azure CLI is available, false otherwise.
LoginWithManagedIdentity(string?)
Registers a step to login with Managed Identity. Used when running inside Azure VMs, App Service, or other Azure-hosted environments.
public void LoginWithManagedIdentity(string? clientId = null)
Parameters
clientIdstringOptional client ID for user-assigned managed identity. If null, uses system-assigned managed identity.
LoginWithServicePrincipal(string?, string?, string?)
Registers a step to login with a Service Principal. Credentials can be passed explicitly or read from environment variables.
public void LoginWithServicePrincipal(string? clientId = null, string? clientSecret = null, string? tenantId = null)
Parameters
clientIdstringApplication (client) ID, or null to use AZURE_CLIENT_ID env var.
clientSecretstringClient secret, or null to use AZURE_CLIENT_SECRET env var.
tenantIdstringTenant ID, or null to use AZURE_TENANT_ID env var.
SetSubscription(string?)
Registers a step to set the active Azure subscription.
public void SetSubscription(string? subscriptionId = null)
Parameters
subscriptionIdstringSubscription ID or name to set as active. If null, uses AZURE_SUBSCRIPTION_ID env var.
ShowAccount()
Registers a step to display current Azure account information. Useful for debugging and verifying which account/subscription is active.
public void ShowAccount()