Lab 08 - Manage Virtual Machines (Task5~Task6)_Cloudshell(用powershell跟bash方式)

 

Task 5: Create a virtual machine using Azure PowerShell 

Use the icon (top right) to launch a Cloud Shell session. Alternately, navigate directly to https://shell.azure.com.

若直接網址列這樣訪問會跳出以下視窗


這邊在登入時候從右上角去點開也OK
選好按Apply


Be sure to select PowerShell. If necessary, configure the shell storage.

Run the following command to create a virtual machine. When prompted, provide a username and password for the VM. While you wait check out the New-AzVM command reference for all the parameters associated with creating a virtual machine.

New-AzVm `
-ResourceGroupName 'AZ-104-M8-A728GIWJRI' `
-Name 'myPSVM' `
-Location 'East US' `
-Image 'Win2019Datacenter' `
-Zone '1' `
-Size 'Standard_D2s_v3' `
-Credential (Get-Credential)



Once the command completes, use Get-AzVM to list the virtual machines in your resource group.
Get-AzVM `
-ResourceGroupName 'AZ-104-M8-A728GIWJRI' `
-Status


Verify your new virtual machine is listed and the Status is Running.



Use Stop-AzVM to deallocate your virtual machine. Type Yes to confirm.

Stop-AzVM `
-ResourceGroupName 'AZ-104-M8-A728GIWJRI' `
-Name 'myPSVM' 


Use Get-AzVM with the -Status parameter to verify the machine is deallocated.


When you use Azure to stop your virtual machine, the status is deallocated. This means that any non-static public IPs are released, and you stop paying for the VM’s compute costs.


Task 6: Create a virtual machine using the CLI

Use the icon (top right) to launch a Cloud Shell session. Alternately, navigate directly to https://shell.azure.com.



Be sure to select Bash. If necessary, configure the shell storage.


Run the following command to create a virtual machine. When prompted, provide a username and password for the VM. While you wait check out the az vm create command reference for all the parameters associated with creating a virtual machine.

az vm create --name myCLIVM --resource-group AZ-104-M8-A728GIWJRI --image Ubuntu2204 --admin-username localadmin --generate-ssh-keys

Once the command completes, use az vm show to verify your machine was created.
Verify the powerState is VM Running.

az vm show --name  myCLIVM --resource-group AZ-104-M8-A728GIWJRI --show-details







Use az vm deallocate to deallocate your virtual machine. Type Yes to confirm.
az vm deallocate --resource-group AZ-104-M8-A728GIWJRI --name myCLIVM

Use az vm show to ensure the powerState is VM deallocated.



留言

這個網誌中的熱門文章

何謂淨重(Net Weight)、皮重(Tare Weight)與毛重(Gross Weight)

(2021年度)駕訓學科筆試準備題庫歸納分析_法規是非題

Architecture(架構) 和 Framework(框架) 有何不同?_軟體設計前的事前規劃的藍圖概念