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. By default the output is an array of strings. Output can be modified using $args{query}.
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 as an object. Take care that this command is always calling the az cli with --json and returns the decoded object. But the format of the object can change accordingly to the provided value of --query. It is also possible that some query result in the function to die on decode_json.
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_as_list(resource_group => 'openqa-rg');
List all availability set in a resource group.
az_vm_as_show(resource_group => 'openqa-rg', name => 'openqa-as');
Show all the details of an availability set. For the moment it only show and does not return anything.
az_img_from_vhd_create(resource_group => $rg, name => $name, source => $uploaded_vhd_url);
Create an image out of a .vhd disk in Azure storage.
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.
It returns the total ammount of time spent waiting or function kills the test on 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_get_id(
resource_group => 'openqa-rg',
name => 'openqa-vm')
Get the NIC ID of the first NIC of a given VM
Create a NIC
Get the NIC data from NIC ID using 'az network nic show'
my $nic_name = az_nic_name_get(
resource_group => 'openqa-rg',
name => 'openqa-vm')
Get the NIC name from NIC ID
az_nic_list(resource_group=>'resource group name' [, query=>'[].name']);
Returns ARRAYREF with all nic names located in resource group. Output can be modified using $args{query}.
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_network_peering_exists(resource_group=>'openqa-rg', vnet=>'openqa-this-vnet', name=>'openqa-fromVNET-toVNET');
Returns 1 (true) if peering resource exists, 0 (false) if it was not found.
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.
my $is_valid = az_validate_uuid_pattern(uuid => $uuid_string);
Validates if a given string matches the standard UUID pattern (e.g.,
C<xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx>). This is commonly used to verify
identifiers for Azure resources.
Return value:
On a successful match, returns the original scalar string containing the UUID. This value is considered true in a boolean context.
On a failed match, returns undef. This value is considered false in a boolean context.
Arguments:
az_storage_blob_upload(
container_name=>'somecontainer',
storage_account_name=>'storageaccount',
file=>'somefilename' [, timeout=>42]);
Uploads file to a storage container.
my $lease_id = az_storage_blob_lease_acquire(
container_name => 'somecontainer',
storage_account_name => 'storageaccount',
blob_name => 'somefilename',
lease_duration => 60
);
Acquire a lease for a storage blob. The function returns a UUID which is then required to modify the file and gives the UUID owner exclusive rights.
If the lease cannot be acquired (e.g., the blob is already leased by another process, or another Azure error occurs), the function will return undef.
Return value:
On success, returns a scalar string containing the lease UUID.
On failure, returns undef. The reasons may vary and it is up to caller to decide how to deal with the result. 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.
az_group_exists(resource_group=>'resource group name' [, quiet=>'pssst!']);
Check if specified resource group exists. Returns true or false.
az_network_vnet_show(resource_group=>'resource group name', name=>'vnet01' [, query=>'[].name']);
Returns HASHREF with all NIC names located in resource group. Output can be modified using $args{query}.
az_network_dns_zone_create(resource_group=>'resource group name', name=>'default.com');
Creates private DNS zone within specified resource_group.
az_network_dns_zone_delete(resource_group=>'resource group name', zone_name=>'default.com');
Deletes private DNS zone within resource_group specified by zone_name.
az_network_dns_zone_list(resource_group=>'resource group name');
Returns private DNS zone list as an ARRAYREF existing within specified resource_group.
az_network_dns_add_record(
resource_group=>'resource group name',
zone_name=>'opensuse.org',
record_name=>'openqa',
ip_addr=>'192.168.1.5'
);
Creates a DNS record inside Private DNS zone $args{zone_name}.
az_network_dns_link_create(
resource_group=>'resource group name',
zone_name='opensuse.org',
vnet=>'vnet_rg',
name=>'link_to_rg_vnet'
);
Creates private DNS zone link between VNET and DNS zone.
az_network_dns_link_delete(
resource_group=>'resource group name',
zone_name='opensuse.org',
link_name=>'link_to_rg_vnet'
);
Deletes private DNS link between VNET and DNS zone.
az_network_dns_link_list(resource_group=>'resource group name', zone_name='opensuse.org', query=>'[].id');
Lists private DNS links withing specified resource_group and zone_name. Result is returned as ARRAYREF.
az_network_dns_links_cleanup(resource_group=>'resource group name');
Searches and deletes all DNS links within specified resource_group. Intended for cleanup to remove nested resource.
az_network_dns_zones_cleanup(resource_group=>'resource group name');
Searches and deletes all DNS zones within specified resource_group.