Sunday, November 20, 2016

Connecting to MS azure CLI using MAC


Azure PowerShell Basics:

Three modules are installed as part of the Azure CLI installation:
1. Azure (Azure Service Management) 
2. AzureResourceManager 
3. AzureProfile 

Two Modes 
Azure Service management  (using subscription certificate and account mode)
Azure Resource Manager (account mode)

--
Download azure CLI code for MAC:

https://go.microsoft.com/fwlink/?LinkId=253471&clcid=0x409

After Installation, Use following commands to use Azure account:
--
$azure config mode asm
$azure account download
$cd Downloads/
$azure account import Microsoft\ Azure\ Sponsorship-11-20-2016-credentials.publishsettings

---
And, the magic begins:

$ azure vm list
info:    Executing command vm list
+ Getting virtual machines
data:    Name          Status              Location      DNS Name                    IP Address
data:    ------------  ------------------  ------------  --------------------------  ----------
data:    JumboTest     StoppedDeallocated  North Europe  jumbotest.cloudapp.net
data:    ADPOCEXCH01   StoppedDeallocated  North Europe  adpocexchange.cloudapp.net
data:    TestExchange  StoppedDeallocated  North Europe  adpocexchange.cloudapp.net
data:    ADPOCNDES01   StoppedDeallocated  North Europe  adpocndes.cloudapp.net
data:    testndes      StoppedDeallocated  North Europe  adpocndes.cloudapp.net
data:    ADPOCAD01     StoppedDeallocated  North Europe  adpocad01.cloudapp.net
data:    ADPOCADFS01   ReadyRole           North Europe  adpocad01.cloudapp.net      10.0.0.7
data:    Alphademorms  ReadyRole           North Europe  rmsalphademo.cloudapp.net   10.0.0.8
data:    Alphapocor01  StoppedDeallocated  North Europe  alphapocor01.cloudapp.net
info:    vm list command OK

-------
ram$ azure vm show testndes
info:    Executing command vm show
+ Getting virtual machines
data:    DNSName "adpocndes.cloudapp.net"
data:    Location "North Europe"
data:    VMName "testndes"
data:    IPAddress ""
data:    InstanceStatus "StoppedDeallocated"
data:    Image "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-20160229-en.us-127GB.vhd"
data:    OSDisk hostCaching "ReadWrite"
data:    OSDisk name "ADPOCNDES01-testndes-0-201604131622120668"
data:    OSDisk mediaLink "https://4wportalvhds1lvpsrpsb7n8.blob.core.windows.net/vhds/ADPOCNDES-testndes-2016-04-13.vhd"
data:    OSDisk sourceImageName "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-20160229-en.us-127GB.vhd"
data:    OSDisk operatingSystem "Windows"
data:    OSDisk iOType "Standard"
data:    ReservedIPName ""
data:    Network Endpoints 0 localPort 5986
data:    Network Endpoints 0 name "PowerShell"
data:    Network Endpoints 0 port 53720
data:    Network Endpoints 0 protocol "tcp"
data:    Network Endpoints 0 enableDirectServerReturn false
data:    Network Endpoints 1 localPort 3389
data:    Network Endpoints 1 name "Remote Desktop"
data:    Network Endpoints 1 port 57498
data:    Network Endpoints 1 protocol "tcp"
data:    Network Endpoints 1 enableDirectServerReturn false
info:    vm show command OK

---Help menu --
ram$ azure help vm

Always check for right login:

etisalat:~ ram$ azure account show
info:    Executing command account show
data:    Name                        : Microsoft Azure Sponsorship
data:    ID                          : 36051sfb8-1ebe-401b-8a07-7ef8f037c747
data:    State                       : Enabled
data:    Tenant ID                   : 2b83df51-c613-s4215-90e2-96265dcf83a2
data:    Is Default                  : true
data:    Environment                 : AzureCloud
data:    Has Certificate             : Yes
data:    Has Access Token            : Yes
data:    User name                   : ramsays@icloud.com


Reference: https://docs.microsoft.com/en-us/azure/virtual-machines-command-line-tools?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json

https://github.com/Azure/azure-xplat-cli

No comments:

Post a Comment