Library to compose and run Azure cli commands
az_version();
Print the version of the az cli available on system
az_group_create(
name => 'openqa-rg',
region => 'westeurope');
Create an Azure resource group in a specific region
my $ret = az_group_name_get();
Get the name of all existing Resource Group in the current subscription
az_group_delete( name => 'openqa-rg' );
Delete a resource group with a specific name
az_network_vnet_create(
resource_group => 'openqa-rg',
region => 'westeurope',
vnet => 'openqa-vnet',
snet => 'openqa-subnet',
address_prefixes => '10.0.1.0/16',
subnet_prefixes => '10.0.1.0/24')
Create a virtual network
az_network_vnet_subnet_update(
resource_group => 'openqa-rg',
vnet => 'openqa-vnet',
snet => 'openqa-subnet',
nat_gateway => 'openqa-nat')
Update a Subnet
my $res = az_network_vnet_get(resource_group => 'openqa-rg')
Return the output of az network vnet list
az_network_nsg_create(
resource_group => 'openqa-rg',
name => 'openqa-nsg')
Create a network security group
az_network_nsg_rule_create(
resource_group => 'openqa-rg',
nsg => 'openqa-nsg',
name => 'openqa-nsg-rule-ssh',
port => 22)
Create a very specific type of inbound rule for an existing network security group Just few parameters are configurable here, like the port number
az_network_publicip_create(
resource_group => 'openqa-rg',
name => 'openqa-pip',
zone => '1 2 3')
Create an IPv4 public IP resource
az_network_publicip_get(
resource_group => 'openqa-rg',
name => 'openqa-pip')
Return an IPv4 public IP address from its name
az_network_nat_gateway_create(
resource_group => 'openqa-rg',
region => 'westeurope',
name => 'openqa-nat-gateway',
public_ip => 'openqa-pubip')
Create a NAT Gateway
az_network_lb_create(
resource_group => 'openqa-rg',
name => 'openqa-lb',
vnet => 'openqa-vnet',
snet => 'openqa-subnet',
backend => 'openqa-be',
frontend_ip_name => 'openqa-feip',
sku => 'Standard')
Create a load balancer entity. LB is mostly "just" a "group" definition to link back-end and front-end resources (usually an IP)
SKU Standard (and not Basic) is needed to get some Metrics
az_network_lb_probe_create(
resource_group => 'openqa-rg',
lb_name => 'openqa-lb',
name => 'openqa-lb-hp',
port => '4242',
protocol => 'Udp',
)
Create a load balancer health probe.
az_network_lb_rule_create(
resource_group => 'openqa-rg',
lb_name => 'openqa-lb',
hp_name => 'openqa-hb',
frontend_ip => 'openqa-fe',
backend => 'openqa-be',
name => 'openqa-lb-rule',
port => '80'
)
Configure the load balancer behavior.
az_vm_as_create(
resource_group => 'openqa-rg',
region => 'westeurope',
name => 'openqa-as',
fault_count => 2)
Create an availability set. Later on VM can be assigned to it.
az_vm_create(
resource_group => 'openqa-rg',
region => 'westeurope',
name => 'openqa-vm',
image => 'SUSE:sles-sap-15-sp5:gen2:latest')
Create a virtual machine
my $ret = az_vm_list(resource_group => 'openqa-rg', query => '[].name');
Get the info from all existing VMs within a Resource Group Return a decoded json hash according to the provided jmespath query
my $res = az_vm_instance_view_get(
resource_group => 'openqa-rg',
name => 'openqa-vm')
Get some details of a specific VM
Json output looks like:
[ "PowerState/running", "VM running" ]
my $res = az_vm_wait_running(
resource_group => 'openqa-rg',
name => 'openqa-vm',
timeout => 300)
Get the VM state until status looks like:
[ "PowerState/running", "VM running" ]
or reach timeout. Polling frequency is dynamically calculated based on the timeout
az_vm_openport(
resource_group => 'openqa-rg',
name => 'openqa-vm',
port => 80)
Open a port on an existing VM
az_vm_wait_cloudinit(
resource_group => 'openqa-rg',
name => 'openqa-vm')
Wait cloud-init completion on a running VM
my $nic_id = az_nic_id_get(
resource_group => 'openqa-rg',
name => 'openqa-vm')
Get the NIC ID of the first NIC of a given VM
Get the NIC data from NIC ID
my $nic_name = az_nic_name_get(
resource_group => 'openqa-rg',
name => 'openqa-vm')
Get the NIC name from NIC ID
my $ipconfig_name = az_ipconfig_name_get(
resource_group => 'openqa-rg',
name => 'openqa-vm')
Get the name of the first IpConfig of a NIC from a NIC ID
az_ipconfig_update(
resource_group => 'openqa-rg',
ipconfig_name => 'openqa-ipconfig',
nic_name => 'openqa-nic',
ip => '192.168.0.42')
Change the IpConfig to use a static IP
az_ipconfig_delete(
resource_group => 'openqa-rg',
ipconfig_name => 'openqa-ipconfig',
nic_name => 'openqa-nic')
Delete a specific IpConfig to use a static IP
az_ipconfig_pool_add(
resource_group => 'openqa-rg',
lb_name => 'openqa-lb',
address_pool => 'openqa-addr-pool',
ipconfig_name => 'openqa-ipconfig',
nic_name => 'openqa-nic')
Add the IpConfig to a LB address pool
az_vm_diagnostic_log_enable(resource_group => 'openqa-rg',
storage_account => 'openqasa',
vm_name => 'openqa-vm')
Enable diagnostic log for a specific VM
my $list_of_logs = az_vm_diagnostic_log_get(resource_group => 'openqa-rg')
Call `az vm boot-diagnostics json` for each running VM in the resource group associated to this openQA job
Return a list of diagnostic file paths on the JumpHost
az_storage_account_create(
resource_group => 'openqa-rg',
region => 'westeurope'
name => 'openqasa')
Create a storage account
az_network_peering_create(
name => 'openqa-fromVNET-toVNET',
source_rg => 'openqa-rg',
source_vnet => 'openqa-this-vnet',
target_rg => 'openqa-rg',
target_vnet => 'openqa-this-vnet')
Create network peering
my $res = az_network_peering_list(
resource_group => 'openqa-rg',
vnet => 'openqa-this-vnet' [, query=>'[].name'])
Return HASH representing existing net peering
az_network_peering_delete(
name => 'openqa-fromVNET-toVNET',
resource_group => 'openqa-rg',
vnet => 'openqa-this-vnet')
Delete a specific network peering
az_disk_create(resource_group=>$resource_group, name=>$name
[, size_gb=>60, source=$source, tags="tag1=value1 tag2=value2"]);
Creates new disk device either by specifying size_gb or by cloning another disk device using argument source. Arguments size_gb and source are mutually exclusive.
az_resource_delete(resource_group=>$resource_group, name=>$name);
Deletes resource from specified resource group. Single resource can be deleted by specifying name or list of resource IDs delimited by empty space using argument ids. Arguments name and ids are mutually exclusive. Function returns `az` command exit code.
az_resource_list([resource_group=>$resource_group, query=>$query, output=>$output]);
Lists existing az resources based on arguments provided. Calling function without any argument returns full information from all existing resource groups. Returns decoded json structure if json format is requested, otherwise whole output is a string.
az_validate_uuid_pattern( uuid => $uuid_string )
Function checks input string against uuid pattern
which is commonly used as an identifier for Azure resources.
returns uuid (true) on match, 0 (false) on mismatch.
az_storage_blob_upload(
container_name=>'somecontainer',
storage_account_name=>'storageaccount',
file=>'somefilename' [, timeout=>42]);
Uploads file to a storage container.
az_storage_blob_lease_acquire(
container_name=>'somecontainer',
storage_account_name=>'storageaccount',
blob_name => 'somefilename' [, lease_duration=>'42']
);
Acquire a lease for a storage blob. Function returns UUID which is then required to modify the file and gives the UUID owner exclusive rights. Optionally lease_duration can be defined to limit this file lock up to 60s instead of infinity. In case of function returns nothing, the reasons may vary and it is up to caller to decide how to deal with the result. In that case Possible reasons are that there is already a lease present (az cli returns a message which is not a valid UUID)
az_storage_blob_list(
container_name=>'somecontainer',
storage_account_name=>'storageaccount' [, query=>'[].name']
);
List information about storage blob(s) specified by storage_account_name, container_name and query.
az_storage_blob_update(container_name=>'container', account_name=>'stuff', name='blobby' [, lease_id=42]);
Update properties of storage blob. Returns az cli command exit code.
az_keyvault_list(resource_group=>'resource group' [, query=>'[].id']);
Lists all keyvault resource names located in specified resource group. Output can be modified using query argument.
az_keyvault_secret_list(vault_name=>'Gringotts' [, query=>'[].id']);
Lists all keyvault secret names located in specified keyvault. Output can be modified using query argument.
az_keyvault_secret_show(id=>'someid'
[, name=>'Vault 713', vault_name=>'Gringotts', query=>'[].id', output=>'json', save_to_file=>'/alohomora']);
Lists all keyvault secret names located in specified keyvault. Output can be modified using query argument.