Metadata-Version: 2.1
Name: stack-hci-vm
Version: 1.16.0
Summary: Microsoft Azure Command-Line Tools Stack-HCi-VM Extension
Home-page: https://github.com/Azure/azure-cli-extensions/tree/master/src/stack-hci-vm
Author: Microsoft Corporation
Author-email: azpycli@microsoft.com
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: License :: OSI Approved :: MIT License
Requires-Dist: kubernetes ==24.2.0
Requires-Dist: websocket-client >=1.0.0
Requires-Dist: PyYAML >=5.4.0

# Azure CLI stack-hci-vm Extension #
This is the extension for stack-hci-vm

### How to use ###
Install this extension using the below CLI command
```
az extension add --name stack-hci-vm
```

### Included Features ###
#### stack-hci-vm galleryimage ####
##### Create #####
```
az stack-hci-vm galleryimage create \
    --extended-location name="/subscriptions/a95612cb-f1fa-4daa-a4fd-272844fa512c/resourceGroups/dogfoodarc/providers/Microsoft.ExtendedLocation/customLocations/dogfood-location" type="CustomLocation" \
    --location "West US2" --container-name "Default_Container" --image-path "C:\\\\test.vhdx" \
    --galleryimages-name "test-gallery-image" --resource-group "test-rg" 
```
##### List #####
```
az stack-hci-vm galleryimage list --resource-group "test-rg"
```
##### Update #####
```
az stack-hci-vm galleryimage update --tags additionalProperties="sample" --galleryimages-name "test-gallery-image" \
    --resource-group "test-rg" 
```
##### Retrieve #####
```
az stack-hci-vm galleryimage retrieve --galleryimages-name "test-gallery-image" --resource-group "test-rg"
```
##### Delete #####
```
az stack-hci-vm galleryimage delete --galleryimages-name "test-gallery-image" --resource-group "test-rg"
```
#### stack-hci-vm networkinterface ####
##### Create #####
```
az stack-hci-vm networkinterface create \
    --extended-location name="/subscriptions/a95612cb-f1fa-4daa-a4fd-272844fa512c/resourceGroups/dogfoodarc/providers/Microsoft.ExtendedLocation/customLocations/dogfood-location" type="CustomLocation" \
    --name "test-nic"
    --location "West US2" \
    --subnet-id" "test-lnet" --ip-address "1.2.3.4"

OR

az stack-hci-vm networkinterface create \
    --extended-location name="/subscriptions/a95612cb-f1fa-4daa-a4fd-272844fa512c/resourceGroups/dogfoodarc/providers/Microsoft.ExtendedLocation/customLocations/dogfood-location" type="CustomLocation" \
    --location "West US2" \
    --ip-configurations "[{\"name\":\"ipconfig-sample\",\"properties\":{\"subnet\":{\"id\":\"test-lnet\"},\"ip_address\":\"1.2.3.4\"}}]" \
    --networkinterfaces-name "test-nic"
```
##### List #####
```
az stack-hci-vm networkinterface list --resource-group "test-rg"
```
##### Update #####
```
az stack-hci-vm networkinterface update --tags additionalProperties="sample" --networkinterfaces-name "test-nic" \
    --resource-group "test-rg" 
```
##### Retrieve #####
```
az stack-hci-vm networkinterface retrieve --networkinterfaces-name "test-nic" --resource-group "test-rg"
```
##### Delete #####
```
az stack-hci-vm networkinterface delete --networkinterfaces-name "test-nic" --resource-group "test-rg"
```
#### stack-hci-vm virtualharddisk ####
##### Create #####
```
az stack-hci-vm virtualharddisk create --resource-group "test-rg" \
    --extended-location name="/subscriptions/a95612cb-f1fa-4daa-a4fd-272844fa512c/resourceGroups/dogfoodarc/providers/Microsoft.ExtendedLocation/customLocations/dogfood-location" type="CustomLocation" \
    --location "West US2" --disk-size-gb 32 --virtualharddisks-name "test-vhd" 
```
##### List #####
```
az stack-hci-vm virtualharddisk list --resource-group "test-rg"
```
##### Update #####
```
az stack-hci-vm virtualharddisk update --resource-group "test-rg" --tags additionalProperties="sample" \
    --virtualharddisks-name "test-vhd" 
```
##### Retrieve #####
```
az stack-hci-vm virtualharddisk retrieve --resource-group "test-rg" --virtualharddisks-name "test-vhd"
```
##### Delete #####
```
az stack-hci-vm virtualharddisk delete --resource-group "test-rg" --virtualharddisks-name "test-vhd"
```
#### stack-hci-vm virtualmachine ####
##### Create #####
```
az stack-hci-vm virtualmachine create --resource-group "test-rg" \
    --extended-location name="/subscriptions/a95612cb-f1fa-4daa-a4fd-272844fa512c/resourceGroups/dogfoodarc/providers/Microsoft.ExtendedLocation/customLocations/dogfood-location" type="CustomLocation" \
    --location "West US2" --hardware-profile vm-size="Default" maximum_memory_mb=1 minimum_memory_mb=1 target_memory_buffer=100  --network-profile network-interfaces={"id":"test-nic"} \
    --os-profile "{\\"adminPassword\\":\\"password\\",\\"adminUsername\\":\\"localadmin\\",\\"computerName\\":\\"luamaster\\"}" \
    --storage-profile "{\\"imageReference\\":{\\"id\\":\\"test-gallery-image\\"}}" --virtualmachines-name "test-vm" 
    ----linux-configuration ssh_keys='{\"key_data\": \"ssh_public_key\"}' ssh_keys='{\"path\": \"/path/to/id_rsa.pub\"}'
```
##### List #####
```
az stack-hci-vm virtualmachine list --resource-group "test-rg"
```
##### Update #####
```
az stack-hci-vm virtualmachine update --resource-group "test-rg" --tags additionalProperties="sample" \
    --virtualmachines-name "test-vm" 
```
##### Retrieve #####
```
az stack-hci-vm virtualmachine retrieve --resource-group "test-rg" --virtualmachines-name "test-vm"
```
##### Start #####
```
az stack-hci-vm virtualmachine start --resource-group "test-rg" --virtualmachines-name "test-vm"
```
##### Stop #####
```
az stack-hci-vm virtualmachine stop --resource-group "test-rg" --virtualmachines-name "test-vm"
```
##### Stop (Immediate - Skip Graceful Shutdown) #####
```
az stack-hci-vm virtualmachine stop --resource-group "test-rg" --virtualmachines-name "test-vm" --skip-shutdown
```
##### Delete #####
```
az stack-hci-vm virtualmachine delete --resource-group "test-rg" --virtualmachines-name "test-vm"
```
##### Add Vnic #####
```
az stack-hci-vm virtualmachine vnic add --resource-group "test-rg" --virtualmachines-name "test-vm" --vnic-name "test-vnic"
```
##### Remove Vnic #####
```
az stack-hci-vm virtualmachine vnic remove --resource-group "test-rg" --virtualmachines-name "test-vm" --vnic-name "test-vnic"
```
##### Serial Console Connect #####
Connects to the serial console of a virtual machine, providing direct console access for troubleshooting and administration.

**Prerequisites:**
- The VM must be running on Azure Rack scale
- Kubernetes connectivity must be available 
- User must have privilege access the cluster and must have a cluster role binding

**Basic Usage:**
```
az stack-hci-vm serial-console connect --vm-name "test-vm" --vm-rg "test-rg"
```

**Example with all parameters:**
```
az stack-hci-vm serial-console connect \
    --vm-name "my-windows-vm" \
    --vm-rg "my-resource-group"
```

**Console Control:**
- Press `Ctrl+]` to exit the console session
- Console output is automatically filtered to remove Windows control sequences for better readability
- Raw console output can be accessed if needed for debugging

**Troubleshooting:**
- Ensure the VM has a valid extended location configured
- Verify Azure Stack HCI Administrator role is assigned
- Check that the connected Kubernetes cluster is accessible
- If the command works once but fails on subsequent runs, the Kubernetes client cache may need to be refreshed

#### stack-hci-vm logicalnetwork ####
##### Create #####

A Static logical network is backed by a Managed Network Fabric L3 isolation domain
internal network:

```
az stack-hci-vm network lnet create \
  --resource-group "test-rg" \
  --name "test-lnet" \
  --location "eastus2euap" \
  --tags env=prod \
  --custom-location "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.ExtendedLocation/customLocations/test-location" \
  --address-prefixes "10.0.0.0/16" \
  --ip-allocation-method Static \
  --ip-pool-type "vm" \
  --ip-pool-start "10.0.0.0" \
  --ip-pool-end "10.0.0.16" \
  --vlan 10 \
  --vm-switch-name "sampleVnet0920" \
  --dns-servers 8.8.8.8 8.8.4.4 \
  --fabric-network-configuration-id "/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/l3IsolationDomains/example-l3domain/internalNetworks/example-internal-network" \
  --gateway 10.0.0.1 \
  --network-security-group "myNSG"
```

A Dynamic logical network is backed by a Managed Network Fabric L2 isolation domain.
It takes its address configuration, gateway and DNS servers from DHCP, so
`--address-prefixes`, `--ip-pools`, `--dns-servers` and `--gateway` are not accepted:

```
az stack-hci-vm network lnet create \
  --resource-group "test-rg" \
  --name "test-dynamic-lnet" \
  --location "eastus2euap" \
  --custom-location "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.ExtendedLocation/customLocations/test-location" \
  --ip-allocation-method Dynamic \
  --vlan 10 \
  --vm-switch-name "sampleVnet0920" \
  --fabric-network-configuration-id "/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/l2IsolationDomains/example-l2domain"
```

Note that the IP allocation method is Dynamic when `--ip-allocation-method` is not
specified. These pairing rules only apply when `--fabric-network-configuration-id`
is supplied; logical networks without a fabric reference are unaffected.

##### List #####
```
az stack-hci-vm network lnet list --resource-group "test-rg"
```
##### Update #####
```
az stack-hci-vm network lnet update --resource-group $rg --tags additionalProperties="sample" --name "test-lnet"
```
##### Show #####
```
az stack-hci-vm network lnet show --resource-group "test-rg" --name "test-lnet"
```
##### Delete #####
```
az stack-hci-vm network lnet delete --resource-group "test-rg" --name "test-lnet"
```

#### stack-hci-vm vnet ####
##### Create #####
```
az stack-hci-vm network vnet create \
  --resource-group "test-rg" \
  --name "test-vnet" \
  --location "eastus" \
  --tags env=prod owner=admin \
  --custom-location "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.ExtendedLocation/customLocations/test-location" \
  --address-prefixes "10.0.0.0/16" "10.1.0.0/16" \
  --dns-servers 8.8.8.8 8.8.4.4 \
  --polling-interval 30
```
##### List #####
```
az stack-hci-vm network vnet list --resource-group "test-rg"
```
##### Update #####
```
az stack-hci-vm network vnet update --resource-group "test-rg" --name "test-vnet" --tags env=prod updated=yes
```
##### Show #####
```
az stack-hci-vm network vnet show --name "test-vnet" --resource-group "test-rg"
```
##### Delete #####
```
az stack-hci-vm network vnet delete --name "test-vnet" --resource-group "test-rg" --yes
```

#### stack-hci-vm subnet ####
##### Create #####
```
az stack-hci-vm network vnet subnet create \
  --resource-group "test-rg" \
  --vnet-name "test-vnet" \
  --name "test-subnet" \
  --location "eastus" \
  --tags env=prod subnettype=backend \
  --custom-location "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.ExtendedLocation/customLocations/test-location" \
  --address-prefix "10.0.0.0/24" \
  --network-security-group "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/networkSecurityGroups/test-nsg" \
  --nat-gateway "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/natGateways/test-nat" \
  --routes '[{"name":"default","address_prefix":"0.0.0.0/0","next_hop_ip_address":"10.0.0.1"}]' \
  --polling-interval 30
```
##### List #####
```
az stack-hci-vm network vnet subnet list --resource-group "test-rg" --vnet-name "test-vnet"
```
##### Update #####
```
az stack-hci-vm network vnet subnet update --resource-group "test-rg" --vnet-name "test-vnet" --name "test-subnet" --network-security-group "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/networkSecurityGroups/test-nsg" --nat-gateway "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/natGateways/test-nat" --tags env=prod updated=yes
```
##### Show #####
```
az stack-hci-vm network vnet subnet show --vnet-name "test-vnet" --name "test-subnet" --resource-group "test-rg"
```
##### Delete #####
```
az stack-hci-vm network vnet subnet delete --vnet-name "test-vnet" --name "test-subnet" --resource-group "test-rg" --yes
```

#### stack-hci-vm nat ####
##### Create #####
```
az stack-hci-vm network nat create \
  --resource-group "test-rg" \
  --name "test-nat" \
  --location "eastus" \
  --public-ip-address-ids \
      "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/publicIPAddresses/test-pip1" \
      "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/publicIPAddresses/test-pip2" \
  --inbound-nat-rules '[
      {
        "name": "sshRule",
        "protocol": "Tcp",
        "frontend_port": 2222,
        "backend_port": 22,
        "backend_ip_config_id": "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/networkInterfaces/vm1nic/ipConfigurations/ipconfig1",
        "public_ip_id": "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/publicIPAddresses/test-pip1"
      },
      {
        "name": "rdpRule",
        "protocol": "Tcp",
        "frontend_port": 50001,
        "backend_port": 3389,
        "backend_ip_config_id": "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/networkInterfaces/vm2nic/ipConfigurations/ipconfig1",
        "public_ip_id": "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/publicIPAddresses/test-pip2"
      }
    ]' \
  --tags env=prod nat=yes \
  --custom-location "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.ExtendedLocation/customLocations/test-location"

```
##### List #####
```
az stack-hci-vm network nat list --resource-group "test-rg"
```
##### Update #####
```
az stack-hci-vm network nat update --resource-group "test-rg" --name "test-nat" --tags env=prod updated=yes
```
##### Show #####
```
az stack-hci-vm network nat show --name "test-nat" --resource-group "test-rg"
```
##### Delete #####
```
az stack-hci-vm network nat delete --name "test-nat" --resource-group "test-rg" --yes
```

#### stack-hci-vm lb ####
##### Create #####
```
az stack-hci-vm network lb create --resource-group "test-rg" --name "test-lb" --location "eastus" --frontend-ip-config-names "fe1" "fe2" --frontend-ip-private-addresses 10.0.0.4 10.0.0.5 --frontend-ip-allocation-methods Static Dynamic --frontend-ip-subnet-ids "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-subnet1" "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-subnet2" --frontend-ip-public-ip-ids "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/publicIPAddresses/test-pip1" "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/publicIPAddresses/test-pip2" --backend-pool-names "be1" "be2" --backend-pool-backend-addresses '[{"name":"be1","admin_state":"Up","network_interface_ip_configuration":"/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/networkInterfaces/test-nic1/ipConfigurations/ipconfig1"}]' --backend-pool-virtual-network-ids "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet" --lb-rule-names "rule1" "rule2" --lb-rule-frontend-ip-config-names "fe1" "fe2" --lb-rule-backend-pool-names "be1" "be2" --lb-rule-frontend-ports 80 443 --lb-rule-backend-ports 8080 8443 --lb-rule-protocols Tcp Udp --lb-rule-probe-names "probe1" "probe2" --lb-rule-load-distributions Default SourceIP --lb-rule-idle-timeouts 4 5 --probe-names "probe1" "probe2" --probe-protocols Tcp Tcp --probe-ports 80 443 --probe-request-paths "/" "/health" --probe-intervals 5 5 --probe-num-probes 2 2 --tags env=prod lb=yes --custom-location "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.ExtendedLocation/customLocations/test-location"
```
##### List #####
```
az stack-hci-vm network lb list --resource-group "test-rg"
```
##### Update #####
```
az stack-hci-vm network lb update --resource-group "test-rg" --name "test-lb" --tags env=prod updated=yes
```
##### Show #####
```
az stack-hci-vm network lb show --name "test-lb" --resource-group "test-rg"
```
##### Delete #####
```
az stack-hci-vm network lb delete --name "test-lb" --resource-group "test-rg" --yes
```

#### stack-hci-vm public-ip ####
##### Create #####
```
az stack-hci-vm network public-ip create --resource-group "test-rg" --name "test-pip" --location "eastus" --version IPv4 --allocation-scope /subscriptions/a95612cb-f1fa-4daa-a4fd-272844fa512c/resourceGroups/MyHciRg/providers/Microsoft.AzureStackHCI/logicalNetworks/MyLnet --ip-address 20.30.40.50 --tags env=prod pip=yes --custom-location "/subscriptions/xxxx/resourceGroups/test-rg/providers/Microsoft.ExtendedLocation/customLocations/test-location"
```
##### List #####
```
az stack-hci-vm network public-ip list --resource-group "test-rg"
```
##### Update #####
```
az stack-hci-vm network public-ip update --resource-group "test-rg" --name "test-pip" --tags env=prod updated=yes
```
##### Show #####
```
az stack-hci-vm network public-ip show --name "test-pip" --resource-group "test-rg"
```
##### Delete #####
```
az stack-hci-vm network public-ip delete --name "test-pip" --resource-group "test-rg" --yes
```
#### stack-hci-vm storagecontainer ####
##### Create #####
```
az stack-hci-vm storagecontainer create --resource-group "test-rg" \
    --extended-location name="/subscriptions/a95612cb-f1fa-4daa-a4fd-272844fa512c/resourceGroups/dogfoodarc/providers/Microsoft.ExtendedLocation/customLocations/dogfood-location" type="CustomLocation" \
    --location "West US2" --path "C:\\\\container_storage" --storagecontainers-name "Default_Container" 
```
##### List #####
```
az stack-hci-vm storagecontainer list --resource-group "test-rg"
```
##### Update #####
```
az stack-hci-vm storagecontainer update --resource-group "test-rg" --tags additionalProperties="sample" \
    --storagecontainers-name "Default_Container" 
```
##### Retrieve #####
```
az stack-hci-vm storagecontainer retrieve --resource-group "test-rg" --storagecontainers-name "Default_Container"
```
##### Delete #####
```
az stack-hci-vm storagecontainer delete --resource-group "test-rg" --storagecontainers-name "Default_Container"
```
#### stack-hci-vm cluster ####
##### Create #####
```
az stack-hci-vm cluster create --location "East US" --aad-client-id "24a6e53d-04e5-44d2-b7cc-1b732a847dfc" \
    --aad-tenant-id "7e589cc1-a8b6-4dff-91bd-5ec0fa18db94" --name "myCluster" --resource-group "test-rg" 
```
##### Show #####
```
az stack-hci-vm cluster show --name "myCluster" --resource-group "test-rg"
```
##### List #####
```
az stack-hci-vm cluster list --resource-group "test-rg"
```
##### Update #####
```
az stack-hci-vm cluster update --tags tag1="value1" tag2="value2" --name "myCluster" --resource-group "test-rg"
```
##### Delete #####
```
az stack-hci-vm cluster delete --name "myCluster" --resource-group "test-rg"
```


