Cloud Shell Tips for SysAdmins Part V - The One Liner Guide

%3CLINGO-SUB%20id%3D%22lingo-sub-1369928%22%20slang%3D%22en-US%22%3ECloud%20Shell%20Tips%20for%20SysAdmins%20Part%20V%20-%20The%20One%20Liner%20Guide%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1369928%22%20slang%3D%22en-US%22%3E%3CDIV%20id%3D%22article-body%22%20class%3D%22body%22%20data-article-id%3D%22329693%22%3E%0A%3CP%3EThe%20Azure%20CLI%20is%20one%20of%20the%20real%20benefits%20of%20getting%20to%20work%20with%20the%20Azure%20Resource%20Manager.%20Whether%20you%20are%20running%20it%20from%20a%20local%20workstation%20or%20using%20the%20Azure%20Cloud%20Shell%2C%20you%20can%20always%20count%20on%20Aure%20CLI%20to%20help%20make%20managing%20your%20deployments%20and%20accounts%20easier.%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22jaydestro_0-1588866273600.jpeg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F189802i70D0B7E7042D7A85%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22jaydestro_0-1588866273600.jpeg%22%20alt%3D%22jaydestro_0-1588866273600.jpeg%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fres.cloudinary.com%2Fpracticaldev%2Fimage%2Ffetch%2Fs--7zjMb1jn--%2Fc_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_880%2Fhttps%3A%2F%2Fres.cloudinary.com%2Fpracticaldev%2Fimage%2Ffetch%2Fs--6tCHgFI1--%2Fc_limit%25252Cf_auto%25252Cfl_progressive%25252Cq_auto%25252Cw_880%2Fhttps%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Flp775ze0xum9udzuo67n.png%22%20border%3D%220%22%20alt%3D%22lp775ze0xum9udzuo67n%22%20%2F%3E%3C%2FP%3E%0A%3CP%3EI'll%20provide%20you%20with%20a%20quick%20getting%20started%20guide%20with%20some%20links%20from%20the%20Microsoft%20Azure%20Docs%20site.%20I%20will%20also%20share%20some%20of%20my%20favorite%20Azure%20CLI%20commands%20or%20%22one%20liners%22%20that%20you%20can%20use%20in%20your%20bash%20shell%20with%20Azure%20CLI.%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1353390091%22%20id%3D%22toc-hId--1353390091%22%3E%3CA%20class%3D%22anchor%22%20href%3D%22https%3A%2F%2Fdev.to%2Fazure%2Fcloud-shell-tips-for-sysadmins-part-v-the-one-liner-guide-158h%23getting-started%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20name%3D%22getting-started%22%3E%3C%2FA%3EGetting%20started%3C%2FH2%3E%0A%3CP%3EUsing%20the%20Azure%20CLI%20starts%20with%20choosing%20whether%20to%20install%20it%2C%20or%20not.%20Let%20me%20explain%20what%20I%20mean!%20The%20Azure%20CLI%20can%20be%20run%20on%20your%20local%20computer%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fcli%2Fazure%2Finstall-azure-cli-windows%3Fview%3Dazure-cli-latest%26amp%3BWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EWindows%3C%2FA%3E%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fcli%2Fazure%2Finstall-azure-cli-macos%3Fview%3Dazure-cli-latest%26amp%3BWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMac%3C%2FA%3E%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fcli%2Fazure%2Finstall-azure-cli-apt%3Fview%3Dazure-cli-latest%26amp%3BWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ELinux%3C%2FA%3E)%2C%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fcli%2Fazure%2Frun-azure-cli-docker%3Fview%3Dazure-cli-latest%26amp%3BWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDocker%20container%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eor%20right%20in%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fcloud-shell%2Fquickstart%3FWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Cloud%20Shell.%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EFollow%20the%20documentation%20guides%20provided%20to%20install%2C%20or%20don't%20and%20use%20Cloud%20Shell.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--662828617%22%20id%3D%22toc-hId--662828617%22%3E%3CA%20class%3D%22anchor%22%20href%3D%22https%3A%2F%2Fdev.to%2Fazure%2Fcloud-shell-tips-for-sysadmins-part-v-the-one-liner-guide-158h%23one-liner-local-mac-install%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20name%3D%22one-liner-local-mac-install%22%3E%3C%2FA%3EOne%20liner%20-%20local%20Mac%20install%20%3Aparty_popper%3A%3C%2FH3%3E%0A%3CP%3EHere's%20a%20one-liner%20for%20Mac%20to%20install%20Azure%20CLI%20locally%2C%20you%20will%20need%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.brew.sh%2FInstallation.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EHomebrew%20package%20manager%3C%2FA%3E%3A%3C%2FP%3E%0A%3CDIV%20class%3D%22highlight%22%3E%0A%3CPRE%20class%3D%22highlight%20plaintext%22%3E%3CCODE%3Ebrew%20update%20%26amp%3B%26amp%3B%20brew%20install%20azure-cli%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3CH2%20id%3D%22toc-hId--673331721%22%20id%3D%22toc-hId--673331721%22%3E%3CA%20class%3D%22anchor%22%20href%3D%22https%3A%2F%2Fdev.to%2Fazure%2Fcloud-shell-tips-for-sysadmins-part-v-the-one-liner-guide-158h%23azure-cloud-shell%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20name%3D%22azure-cloud-shell%22%3E%3C%2FA%3EAzure%20Cloud%20Shell%3C%2FH2%3E%0A%3CP%3EIn%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdev.to%2Fazure%2Fazure-cloud-shell-tips-for-sysadmins-bash-4h2e%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Epart%20one%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ewe%20opened%20up%20the%20Cloud%20Shell%2C%20but%20let's%20take%20a%20quick%20reminder!%3C%2FP%3E%0A%3CP%3EThe%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Ffeatures%2Fcloud-shell%2F%3FWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Cloud%20Shell%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20one%20of%20my%20favorite%20things%20about%20using%20Azure.%20Many%20of%20the%20administrative%20tasks%20that%20I%20may%20have%20had%20to%20run%20from%20a%20local%20computer%20can%20now%20be%20done%20from%20a%20browser%20anywhere%20I%20can%20authenticate%20into%20my%20Azure%20account.%20I%20used%20to%20always%20worry%20about%20needing%20a%20computer%20that%20had%20a%20shell%20or%20a%20terminal%20program%20with%20my%20ssh%20key%20on%20it%20all%20the%20time.%20Now%2C%20I%20am%20keeping%20much%20of%20this%20on%20my%20Azure%20Cloud%20Shell%20so%20I%20can%20work%20pretty%20much%20anywhere.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fres.cloudinary.com%2Fpracticaldev%2Fimage%2Ffetch%2Fs--aM0vxJ67--%2Fc_limit%252Cf_auto%252Cfl_progressive%252Cq_66%252Cw_880%2Fhttps%3A%2F%2Ftva1.sinaimg.cn%2Flarge%2F007S8ZIlgy1gejfcz5z59g30dc07iqv5.gif%22%20border%3D%220%22%20alt%3D%22cli%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20Azure%20Cloud%20Shell%20can%20run%20either%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fcloud-shell%2Fquickstart%3FWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ebash%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eor%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fcloud-shell%2Fquickstart-powershell%3FWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EPowershell%3C%2FA%3E.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3ELaunch%20Cloud%20Shell%20from%20the%20top%20navigation%20of%20the%20Azure%20portal.%3C%2FLI%3E%0A%3CLI%3ESelect%20a%20subscription%20to%20create%20a%20storage%20account%20and%20Microsoft%20Azure%20Files%20share.%3C%2FLI%3E%0A%3CLI%3ESelect%20%22Create%20storage%22%3C%2FLI%3E%0A%3CLI%3ESelect%20the%20Bash%20environment.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EGreat.%20Now%20let's%20open%20a%20new%20tab%20from%20the%20Cloud%20Shell%20and%20get%20a%20full-size%20shell%2C%20or%20you%20can%20just%20navigate%20your%20browser%20to%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fshell.azure.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fshell.aure.com%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20access%20full%20view%3A%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorjaydestro_1%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-17229753%22%20id%3D%22toc-hId-17229753%22%3E%3CA%20class%3D%22anchor%22%20href%3D%22https%3A%2F%2Fdev.to%2Fazure%2Fcloud-shell-tips-for-sysadmins-part-v-the-one-liner-guide-158h%23one-liner-create-an-ssh-keypair%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20name%3D%22one-liner-create-an-ssh-keypair%22%3E%3C%2FA%3EOne%20liner%20-%20create%20an%20ssh%20keypair%20%3Aparty_popper%3A%3C%2FH3%3E%0A%3CP%3EIf%20you%20do%20not%20have%20an%20ssh%20key%20for%20your%20Azure%20bash%20Cloud%20Shell%2C%20or%20in%20your%20local%20terminal%2C%20it's%20very%20simple%20to%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fvirtual-machines%2Flinux%2Fmac-create-ssh-keys%3FWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ecreate%20a%20keypair%3C%2FA%3E%3A%3C%2FP%3E%0A%3CDIV%20class%3D%22highlight%22%3E%0A%3CPRE%20class%3D%22highlight%20shell%22%3E%3CCODE%3Essh-keygen%20%3CSPAN%20class%3D%22nt%22%3E-m%3C%2FSPAN%3E%20PEM%20%3CSPAN%20class%3D%22nt%22%3E-t%3C%2FSPAN%3E%20rsa%20%3CSPAN%20class%3D%22nt%22%3E-b%3C%2FSPAN%3E%204096%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3CP%3Eyou%20can%20find%20this%20newly%20created%20key%20in%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3E~%2F.ssh%2F%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Edirectory%3A%3C%2FP%3E%0A%3CDIV%20class%3D%22highlight%22%3E%0A%3CPRE%20class%3D%22highlight%20plaintext%22%3E%3CCODE%3E%23%20private%20key%0Als%20-al%20~%2F.ssh%2Fid_rsa%0A%0A-rw-------%201%20jay%20jay%201679%20Mar%2014%20%202016%20%2Fhome%2Fjay%2F.ssh%2Fid_rsa%0A%0A%23%20public%20key%0Als%20-al%20~%2F.ssh%2Fid_rsa.pub%0A%0A-rw-r--r--%201%20jay%20jay%20414%20Mar%2014%20%202016%20%2Fhome%2Fjay%2F.ssh%2Fid_rsa.pub%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3CP%3EThe%20private%20key%20is%20important!%20Do%20not%20share%20it!%20The%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3E.pub%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ekey%20is%20what%20you%20will%20specify%20when%20sharing%20the%20key%20on%20a%20Linux%20VM.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1790224710%22%20id%3D%22toc-hId--1790224710%22%3E%3CA%20class%3D%22anchor%22%20href%3D%22https%3A%2F%2Fdev.to%2Fazure%2Fcloud-shell-tips-for-sysadmins-part-v-the-one-liner-guide-158h%23one-liner-list-your-subscription%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20name%3D%22one-liner-list-your-subscription%22%3E%3C%2FA%3EOne%20liner%20-%20list%20your%20subscription%20%3Aparty_popper%3A%3C%2FH3%3E%0A%3CP%3EIf%20I%20run%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fcli%2Fazure%2Faccount%3Fview%3Dazure-cli-latest%26amp%3BWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Efollowing%20command%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3EI%20can%20see%20what%20subscriptions%20I%20am%20subscribted%20to%3A%3C%2FP%3E%0A%3CDIV%20class%3D%22highlight%22%3E%0A%3CPRE%20class%3D%22highlight%20plaintext%22%3E%3CCODE%3Eaz%20account%20list%20--all%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3CDIV%20id%3D%22tinyMceEditorjaydestro_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fres.cloudinary.com%2Fpracticaldev%2Fimage%2Ffetch%2Fs--uszKqBx0--%2Fc_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_880%2Fhttps%3A%2F%2Ftva1.sinaimg.cn%2Flarge%2F007S8ZIlgy1gek8vife3fj31850u0qj5.jpg%22%20border%3D%220%22%20alt%3D%22Screen%20Shot%202020-05-07%20at%209.28.36%20AM%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20%22id%22%20value%20shows%20us%20what%20our%20account%20number%20is%20for%20the%20subscription%20I'd%20like%20to%20create%20resources%20in.%20I've%20obscured%20some%20parts%20of%20it%20above%2C%20but%20the%20account%20number%20is%20a%2036%20character%20string.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-697288123%22%20id%3D%22toc-hId-697288123%22%3E%3CA%20class%3D%22anchor%22%20href%3D%22https%3A%2F%2Fdev.to%2Fazure%2Fcloud-shell-tips-for-sysadmins-part-v-the-one-liner-guide-158h%23one-liner-set-yout-default-subscription%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20name%3D%22one-liner-set-yout-default-subscription%22%3E%3C%2FA%3EOne%20liner%20-%20set%20yout%20default%20subscription%20%3Aparty_popper%3A%3C%2FH3%3E%0A%3CP%3ETo%20pick%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fcli%2Fazure%2Fmanage-azure-subscriptions-azure-cli%3Fview%3Dazure-cli-latest%26amp%3BWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Edefault%20subscription%20for%20your%20account%3C%2FA%3E%2C%20you%20can%20execute%20the%20following%20command%3A%3C%2FP%3E%0A%3CDIV%20class%3D%22highlight%22%3E%0A%3CPRE%20class%3D%22highlight%20plaintext%22%3E%3CCODE%3Eaz%20account%20set%20--subscription%20%22f9bda450-etcetcetc-yourid%22%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3CP%3EWe've%20told%20the%20CLI%20that%20all%20actions%20we%20send%20tot%20he%20Azure%20Resource%20Manager%20will%20be%20default%20to%20the%20%22%3CSTRONG%3Eca-jgord-demo-test%3C%2FSTRONG%3E%22%20subscription.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1110166340%22%20id%3D%22toc-hId--1110166340%22%3E%3CA%20class%3D%22anchor%22%20href%3D%22https%3A%2F%2Fdev.to%2Fazure%2Fcloud-shell-tips-for-sysadmins-part-v-the-one-liner-guide-158h%23one-liner-list-running-vms%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20name%3D%22one-liner-list-running-vms%22%3E%3C%2FA%3EOne%20liner%20-%20list%20running%20VMs%20%3Aparty_popper%3A%3C%2FH3%3E%0A%3CP%3EWe've%20got%20a%20Azure%20CLI%20installation%20going%20or%20using%20the%20cloud%20shell.%20We've%20authenticated%2C%20then%20we%20also%20set%20a%20default%20subscription.%20Time%20to%20get%20some%20details%20on%20running%20resources%20we%20have%20in%20our%20Azure%20account.%20I%20will%20use%20this%20command%20to%20find%20out%20information%20on%20my%20running%20virtual%20machines%3A%3C%2FP%3E%0A%3CDIV%20class%3D%22highlight%22%3E%0A%3CPRE%20class%3D%22highlight%20plaintext%22%3E%3CCODE%3Eaz%20vm%20list%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3CP%3EAl%20the%20VM's%20currently%20running%20int%20he%20context%20of%20the%20default%20subscription%20will%20be%20provided%20by%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Eaz%20cli%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ealong%20with%20details%20about%20their%20deployment.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorjaydestro_3%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fres.cloudinary.com%2Fpracticaldev%2Fimage%2Ffetch%2Fs--Pg4cGA9J--%2Fc_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_880%2Fhttps%3A%2F%2Ftva1.sinaimg.cn%2Flarge%2F007S8ZIlgy1gek8vh1hpxj30xs0u0wv6.jpg%22%20border%3D%220%22%20alt%3D%22az%20vm%20list%20output%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20that%20I%20have%20some%20details%20on%20one%20of%20my%20VM's%2C%20I'd%20like%20to%20open%20RDP%20so%20that%20I%20can%20log%20in%20and%20do%20some%20maintenance.%3C%2FP%3E%0A%3CP%3EI%20want%20to%20work%20with%20servers%20in%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Efunbyte%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eresource%20group.%20This%20will%20require%20a%20security%20change%20to%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fcli%2Fazure%2Fnetwork%2Fnsg%3Fview%3Dazure-cli-latest%26amp%3BWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Enetwork%20security%20group%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eassigned%20to%20the%20VMs.%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-1377346493%22%20id%3D%22toc-hId-1377346493%22%3E%3CA%20class%3D%22anchor%22%20href%3D%22https%3A%2F%2Fdev.to%2Fazure%2Fcloud-shell-tips-for-sysadmins-part-v-the-one-liner-guide-158h%23one-liner-list-your-nsg%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20name%3D%22one-liner-list-your-nsg%22%3E%3C%2FA%3EOne%20liner%20-%20list%20your%20NSG%20%3Aparty_popper%3A%3C%2FH3%3E%0A%3CP%3ELet's%20list%20the%20group%20associated%20with%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3EfunbyteWindows%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eserver%3A%3C%2FP%3E%0A%3CDIV%20class%3D%22highlight%22%3E%0A%3CPRE%20class%3D%22highlight%20plaintext%22%3E%3CCODE%3Eaz%20network%20nsg%20list%20--resource-group%20funbyte%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3CP%3EOur%20JSON%20out%20put%20will%20now%20tell%20us%20the%20name%20of%20our%20nsg%20(%3CCODE%3EfunbyteWindowsNSG%3C%2FCODE%3E)%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorjaydestro_4%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fres.cloudinary.com%2Fpracticaldev%2Fimage%2Ffetch%2Fs--lxQS4RRT--%2Fc_limit%252Cf_auto%252Cfl_progressive%252Cq_auto%252Cw_880%2Fhttps%3A%2F%2Ftva1.sinaimg.cn%2Flarge%2F007S8ZIlgy1gek8vg9fkrj31850u0qj5.jpg%22%20border%3D%220%22%20alt%3D%22nsg%20list%20output%22%20%2F%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--430107970%22%20id%3D%22toc-hId--430107970%22%3E%3CA%20class%3D%22anchor%22%20href%3D%22https%3A%2F%2Fdev.to%2Fazure%2Fcloud-shell-tips-for-sysadmins-part-v-the-one-liner-guide-158h%23one-liner-create-rdp-firewall-rule-for-vm%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20name%3D%22one-liner-create-rdp-firewall-rule-for-vm%22%3E%3C%2FA%3EOne%20liner%20-%20create%20RDP%20firewall%20rule%20for%20VM%20%3Aparty_popper%3A%3C%2FH3%3E%0A%3CP%3EIn%20this%20situation%20we'll%20specify%20we%20want%20to%20open%20port%203389%20temporarily%20to%20my%20IP.%3C%2FP%3E%0A%3CDIV%20class%3D%22highlight%22%3E%0A%3CPRE%20class%3D%22highlight%20plaintext%22%3E%3CCODE%3Eaz%20network%20nsg%20rule%20create%20-g%20funbyte%20--nsg-name%20funbyteWindowsNSG%20-n%20jayRDPule%20%5C%0A%20%20%20%20--priority%20100%20%5C%0A%20%20%20%20--source-address-prefixes%20X.116.99.X%2F32%20--source-port-ranges%203389%20%5C%0A%20%20%20%20--destination-address-prefixes%20'*'%20--destination-port-ranges%203389%20--access%20Allow%20%5C%0A%20%20%20%20--protocol%20Tcp%20--description%20%22Allow%20Jay's%20home%20IP%20to%20RDP.%22%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3CP%3EThis%20single%20command%20allows%20us%20to%20now%20set%20a%20priority%20for%20our%20rule%20permitting%20my%20home%20IP%20address%20access%20to%20port%203389.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorjaydestro_5%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%20id%3D%22tinyMceEditorjaydestro_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--440611074%22%20id%3D%22toc-hId--440611074%22%3E%3CA%20class%3D%22anchor%22%20href%3D%22https%3A%2F%2Fdev.to%2Fazure%2Fcloud-shell-tips-for-sysadmins-part-v-the-one-liner-guide-158h%23whats-next%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%20name%3D%22whats-next%22%3E%3C%2FA%3EWhat's%20next%3F%3C%2FH2%3E%0A%3CP%3EYou've%20got%20the%20tools%2C%20the%20links%20to%20docs%20and%20a%20few%20one%20liners%20to%20help%20you%20as%20a%20SysAdmin%20get%20acclimated%20to%20the%20Azure%20CLI%20and%20Cloud%20Shell.%3C%2FP%3E%0A%3CP%3EIf%20you'd%20like%20to%20get%20more%20training%20for%20free%20on%20this%20subject%2C%20be%20certain%20to%20check%20out%20the%20Microsoft%20Learn%20Module%2C%20%22%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Flearn%2Fmodules%2Fmanage-virtual-machines-with-azure-cli%2F1-what-is-the-cli%3FWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EWhat%20is%20the%20Azure%20CLI%3F%22%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EThis%20module%20contains%20nine%20units%20to%20help%20you%20learn%20even%20more%20about%20how%20to%20use%20the%20Azure%20CLI%20to%20manage%20your%20account.%20Don't%20have%20an%20account%20just%20yet%3F%20Check%20out%20the%20%22%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Flearn%2Fmodules%2Fcreate-an-azure-account%2F%3FWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECreate%20An%20Azure%20Account%3C%2FA%3E%22%20unit%20or%20sign%20up%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Ffree%2F%3FWT.mc_id%3Ddevto-blog-jagord%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%20for%20%24200%20in%20free%20Azure%20credit%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EI%20am%20super%20happy%20to%20help%20you%20more%20on%20your%20journey!%20Reach%20out%20on%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Fjaydestro%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ETwitter%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eor%20just%20leave%20me%20a%20comment!%20Thanks%20so%20much%20for%20being%20part%20of%20Azure.%3C%2FP%3E%0A%3CDIV%20class%3D%22%20fluidvids%22%3E%3CIFRAME%20src%3D%22https%3A%2F%2Fwww.youtube.com%2Fembed%2F8QBl3G_KRXI%22%20width%3D%22710%22%20height%3D%22399%22%20allowfullscreen%3D%22allowfullscreen%22%20class%3D%22%20fluidvids-elem%22%20loading%3D%22lazy%22%20data-mce-fragment%3D%221%22%3E%3C%2FIFRAME%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CDIV%20class%3D%22article-collection-wrapper%20article-collection-wrapper-bottom%22%3E%0A%3CP%3ESysAdmin-Tips%20(5%20Part%20Series)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1369928%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

The Azure CLI is one of the real benefits of getting to work with the Azure Resource Manager. Whether you are running it from a local workstation or using the Azure Cloud Shell, you can always count on Aure CLI to help make managing your deployments and accounts easier.

jaydestro_0-1588866273600.jpeg

lp775ze0xum9udzuo67n

I'll provide you with a quick getting started guide with some links from the Microsoft Azure Docs site. I will also share some of my favorite Azure CLI commands or "one liners" that you can use in your bash shell with Azure CLI.

Getting started

Using the Azure CLI starts with choosing whether to install it, or not. Let me explain what I mean! The Azure CLI can be run on your local computer (Windows, Mac, Linux), a Docker container or right in the Azure Cloud Shell. Follow the documentation guides provided to install, or don't and use Cloud Shell.

One liner - local Mac install :party_popper:

Here's a one-liner for Mac to install Azure CLI locally, you will need the Homebrew package manager:

brew update && brew install azure-cli

Azure Cloud Shell

In part one we opened up the Cloud Shell, but let's take a quick reminder!

The Azure Cloud Shell is one of my favorite things about using Azure. Many of the administrative tasks that I may have had to run from a local computer can now be done from a browser anywhere I can authenticate into my Azure account. I used to always worry about needing a computer that had a shell or a terminal program with my ssh key on it all the time. Now, I am keeping much of this on my Azure Cloud Shell so I can work pretty much anywhere.

 

cli

 

The Azure Cloud Shell can run either bash or Powershell.

  1. Launch Cloud Shell from the top navigation of the Azure portal.
  2. Select a subscription to create a storage account and Microsoft Azure Files share.
  3. Select "Create storage"
  4. Select the Bash environment.

Great. Now let's open a new tab from the Cloud Shell and get a full-size shell, or you can just navigate your browser to https://shell.aure.com to access full view:

 

 

One liner - create an ssh keypair :party_popper:

If you do not have an ssh key for your Azure bash Cloud Shell, or in your local terminal, it's very simple to create a keypair:

ssh-keygen -m PEM -t rsa -b 4096

you can find this newly created key in the ~/.ssh/ directory:

# private key
ls -al ~/.ssh/id_rsa

-rw------- 1 jay jay 1679 Mar 14  2016 /home/jay/.ssh/id_rsa

# public key
ls -al ~/.ssh/id_rsa.pub

-rw-r--r-- 1 jay jay 414 Mar 14  2016 /home/jay/.ssh/id_rsa.pub

The private key is important! Do not share it! The .pub key is what you will specify when sharing the key on a Linux VM.

One liner - list your subscription :party_popper:

If I run the following command I can see what subscriptions I am subscribted to:

az account list --all
 

Screen Shot 2020-05-07 at 9.28.36 AM

 

The "id" value shows us what our account number is for the subscription I'd like to create resources in. I've obscured some parts of it above, but the account number is a 36 character string.

One liner - set yout default subscription :party_popper:

To pick a default subscription for your account, you can execute the following command:

az account set --subscription "f9bda450-etcetcetc-yourid"

We've told the CLI that all actions we send tot he Azure Resource Manager will be default to the "ca-jgord-demo-test" subscription.

One liner - list running VMs :party_popper:

We've got a Azure CLI installation going or using the cloud shell. We've authenticated, then we also set a default subscription. Time to get some details on running resources we have in our Azure account. I will use this command to find out information on my running virtual machines:

az vm list

Al the VM's currently running int he context of the default subscription will be provided by az cli along with details about their deployment.

 

az vm list output

 

Now that I have some details on one of my VM's, I'd like to open RDP so that I can log in and do some maintenance.

I want to work with servers in the funbyte resource group. This will require a security change to the network security group assigned to the VMs.

One liner - list your NSG :party_popper:

Let's list the group associated with the funbyteWindows server:

az network nsg list --resource-group funbyte

Our JSON out put will now tell us the name of our nsg (funbyteWindowsNSG)

 

nsg list output

One liner - create RDP firewall rule for VM :party_popper:

In this situation we'll specify we want to open port 3389 temporarily to my IP.

az network nsg rule create -g funbyte --nsg-name funbyteWindowsNSG -n jayRDPule \
    --priority 100 \
    --source-address-prefixes X.116.99.X/32 --source-port-ranges 3389 \
    --destination-address-prefixes '*' --destination-port-ranges 3389 --access Allow \
    --protocol Tcp --description "Allow Jay's home IP to RDP."

This single command allows us to now set a priority for our rule permitting my home IP address access to port 3389.

 
 

 

What's next?

You've got the tools, the links to docs and a few one liners to help you as a SysAdmin get acclimated to the Azure CLI and Cloud Shell.

If you'd like to get more training for free on this subject, be certain to check out the Microsoft Learn Module, "What is the Azure CLI?"

This module contains nine units to help you learn even more about how to use the Azure CLI to manage your account. Don't have an account just yet? Check out the "Create An Azure Account" unit or sign up here for $200 in free Azure credit.

I am super happy to help you more on your journey! Reach out on Twitter or just leave me a comment! Thanks so much for being part of Azure.

SysAdmin-Tips (5 Part Series)

 

0 Replies