Con Azure-CLI desde Linux administra tu tenant de Azure

Bogota, Diciembre 12 de 2017.

En estos días de inquietud mental, me puse a aprender como usar el Azure-CLI (command Line Interface).

Iniciamos conectándonos a Azure con AZ login, Seleccionamos la suscripción con AZ Account, con AZ interactive iniciamos una sesión interactiva, que nos autocompleta los comandos.

sysadmin@SURFACE:~$ sudo -i

[sudo] password for sysadmin:

root@SURFACE:~# az login

To sign in, use a web browser to open the page https://aka.ms/devicelogin and enter the code FBSYDW8GX to authenticate.

[

{

“cloudName”: “AzureCloud”,

“id”: “6017ae4e-e175-4795-9265-0a775dded652”,

“isDefault”: true,

“name”: “Pay-As-You-Go Dev/Test”,

“state”: “Enabled”,

“tenantId”: “ffb3db32-9dfc-4eae-b841-a4f906b8c449”,

“user”: {

“name”: “fcampo@hotmail.com”,

“type”: “user”

}

},

{

“cloudName”: “AzureCloud”,

“id”: “837632d5-0ee5-468e-aea1-d4290f927a73”,

“isDefault”: false,

“name”: “Plataformas de MSDN”,

“state”: “Enabled”,

“tenantId”: “f35a6d11-e1f6-485b-aedf-cb6735dcc8e6”,

“user”: {

“name”: “fcampo@hotmail.com”,

“type”: “user”

}

}

]

root@SURFACE:~# az –help

 

For version info, use ‘az –version’

 

Group

az

 

Subgroups:

account : Manage subscriptions.

acr : Manage Azure Container Registries.

acs : Manage Azure Container Services.

ad : Synchronize on-premises directories and manage Azure Active Directory

resources.

appservice : Manage your App Service plans.

batch : Manage Azure Batch.

billing : Manage Azure Billing.

cdn : Manage Azure Content Delivery Networks (CDN).

cloud : Manage the registered Azure clouds.

cognitiveservices: Manage Cognitive Services accounts in Azure Resource Manager.

component : Manage and update Azure CLI 2.0 components.

consumption : Manage Azure Consumption.

cosmosdb : Manage Azure Cosmos DB database accounts.

disk : Manage Azure Managed Disks.

dla : Commands to manage Data Lake Analytics accounts, jobs, and catalogs.

dls : Commands to manage Data Lake Store accounts, and filesystems.

feature : Manage resource provider features, such as previews.

functionapp : Manage your function app.

group : Manage resource groups and template deployments.

image : Manage custom Virtual Machine Images.

iot : Connect, monitor, and control millions of IoT assets.

keyvault : Safeguard and maintain control of keys, secrets, and certificates.

lab : Commands to manage DevTest Labs.

lock : Manage Azure locks.

managedapp : Manage template solutions provided and maintained by the ISV using managedapp

and managedapp definitions.

monitor : Commands to manage Azure Monitor service.

mysql : Commands to manage Azure Database for MySQL servers.

network : Manages Azure Network resources.

policy : Manage resource policies.

postgres : Commands to manage Azure Database for PostgreSQL servers.

provider : Manage resource providers.

redis : Access to a secure, dedicated cache for your Azure applications.

resource : Manage Azure resources.

role : Use role assignments to manage access to your Azure resources.

sf : Manage and administer a Service Fabric cluster.

snapshot : Manage point-in-time copies of managed disks, native blobs, or other

snapshots.

sql : Manage Azure SQL Databases and Data Warehouses.

storage : Durable, highly available, and massively scalable cloud storage.

tag : Manage resource tags.

vm : Provision Linux or Windows virtual machines in seconds.

vmss : Create highly available, auto-scalable Linux or Windows virtual machines.

webapp : Manage web apps.

 

Commands:

configure : Configure Azure CLI 2.0 or view your configuration. The command is

interactive, so just type `az configure` and respond to the prompts.

feedback : Loving or hating the CLI? Let us know!

find : Find Azure CLI commands based on a given query.

interactive : Start the interactive experience.

login : Log in to access Azure subscriptions.

logout : Log out to remove access to Azure subscriptions.

 

root@SURFACE:~# az interactive

When in doubt, ask for ‘help’

 

Do you agree to sending telemetry (yes/no)? Default answer is yes: yes

az>> az account list

[

{

“cloudName”: “AzureCloud”,

“id”: “6017ae4e-e175-4795-9265-0a775dded652”,

“isDefault”: true,

“name”: “Pay-As-You-Go Dev/Test”,

“state”: “Enabled”,

“tenantId”: “ffb3db32-9dfc-4eae-b841-a4f906b8c449”,

“user”: {

“name”: “fcampo@hotmail.com”,

“type”: “user”

}

},

{

“cloudName”: “AzureCloud”,

“id”: “837632d5-0ee5-468e-aea1-d4290f927a73”,

“isDefault”: false,

“name”: “Plataformas de MSDN”,

“state”: “Enabled”,

“tenantId”: “f35a6d11-e1f6-485b-aedf-cb6735dcc8e6”,

“user”: {

“name”: “fcampo@hotmail.com”,

“type”: “user”

}

}

]

az>> az account set –subscription “Plataformas de MSDN”

az>> az group create –name myazurelab001 –location eastus2

{

“id”: “/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001”,

“location”: “eastus2”,

“managedBy”: null,

“name”: “myazurelab001”,

“properties”: {

“provisioningState”: “Succeeded”

},

“tags”: null

}

urelab001 –location eastus2 –address-prefixes 10.100.0.0/24 –subnet-name snet001 –subnet-prefix 10.100.0.0/27

{

“newVNet”: {

“addressSpace”: {

“addressPrefixes”: [

“10.100.0.0/24”

]

},

“dhcpOptions”: {

“dnsServers”: []

},

“etag”: “W/\”0e02916a-34f2-45e0-a2f3-89e82fca8ba3\””,

“id”: “/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/virtualNetworks/vnet001”,

“location”: “eastus2”,

“name”: “vnet001”,

“provisioningState”: “Succeeded”,

“resourceGroup”: “myazurelab001”,

“resourceGuid”: “71d144cc-73d5-4a06-a276-b340b55807fc”,

“subnets”: [

{

“addressPrefix”: “10.100.0.0/27”,

“etag”: “W/\”0e02916a-34f2-45e0-a2f3-89e82fca8ba3\””,

“id”: “/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/virtualNetworks/vnet001/subnets/snet001”,

“ipConfigurations”: null,

“name”: “snet001”,

“networkSecurityGroup”: null,

“provisioningState”: “Succeeded”,

“resourceGroup”: “myazurelab001”,

“resourceNavigationLinks”: null,

“routeTable”: null

}

],

“tags”: {},

“type”: “Microsoft.Network/virtualNetworks”,

“virtualNetworkPeerings”: []

}

}

create –name storage001 –resource-group myazurelab001 –location eastus2 –sku Standard_LRS –kind BlobStorage

The storage account named storage001 is already taken.

unt create –name storage00100 –resource-group myazurelab001 –location eastus2 –sku Standard_LRS –kind BlobStorag

The storage account property ‘accessTier’ is invalid or cannot be set at this time.

rage00100 –resource-group myazurelab001 –location eastus2 –sku Standard_LRS –kind BlobStorage –access-tier Cool

{

“accessTier”: “Cool”,

“creationTime”: “2017-07-26T19:48:54.399653+00:00”,

“customDomain”: null,

“encryption”: null,

“id”: “/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001/providers/Microsoft.Storage/storageAccounts/storage00100”,

“kind”: “BlobStorage”,

“lastGeoFailoverTime”: null,

“location”: “eastus2”,

“name”: “storage00100”,

“primaryEndpoints”: {

“blob”: “https://storage00100.blob.core.windows.net/“,

“file”: null,

“queue”: null,

“table”: “https://storage00100.table.core.windows.net/

},

“primaryLocation”: “eastus2”,

“provisioningState”: “Succeeded”,

“resourceGroup”: “myazurelab001”,

“secondaryEndpoints”: null,

“secondaryLocation”: null,

“sku”: {

“name”: “Standard_LRS”,

“tier”: “Standard”

},

“statusOfPrimary”: “available”,

“statusOfSecondary”: null,

“tags”: {},

“type”: “Microsoft.Storage/storageAccounts”

}

az>> az ad app list

[

{

“appId”: “15e431d4-7ab0-4f8d-a3c8-afd0bd271aca”,

“appPermissions”: null,

“availableToOtherTenants”: false,

“displayName”: “heraclito_yMJkalX/21DJERDukzmq5XZ6yshUhyHTZsEDIrqe6m4=”,

“homepage”: “https://management.azure.com//subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourcegroups/rg_campohenriquez/providers/Microsoft.Automation/automationAccounts/heraclito“,

“identifierUris”: [

https://spn/yMJkalX%2f21DJERDukzmq5XZ6yshUhyHTZsEDIrqe6m4%3d

],

“objectId”: “cfadc5e8-e497-43c7-8807-4b636e668cb1”,

“objectType”: “Application”,

“replyUrls”: []

}

]

az>> az ad app delete –id 15e431d4-7ab0-4f8d-a3c8-afd0bd271aca

az>> az ad app list

[]

az>> az ad user list

[

{

“displayName”: “Fabian Alberto Campo Henriquez”,

“mail”: null,

“mailNickname”: “fcampo_hotmail.com#EXT#”,

“objectId”: “d6877962-a794-454d-bd2f-cc5a4a7dc1ed”,

“objectType”: “User”,

“signInName”: null,

“userPrincipalName”: “fcampo_hotmail.com#EXT#@salondelmal.onmicrosoft.com”

},

{

“displayName”: “Luis Ronderos”,

“mail”: null,

“mailNickname”: “Luis.Ronderos”,

“objectId”: “d284a888-db3f-4e23-a733-4c65090d5d7f”,

“objectType”: “User”,

“signInName”: null,

“userPrincipalName”: “Luis.Ronderos@salondelmal.onmicrosoft.com”

}

]

az>> az ad user delete –upn-or-object-id luis.ronderos@salondelmal.onmicrosoft.com

az>> az ad user list

[

{

“displayName”: “Fabian Alberto Campo Henriquez”,

“mail”: null,

“mailNickname”: “fcampo_hotmail.com#EXT#”,

“objectId”: “d6877962-a794-454d-bd2f-cc5a4a7dc1ed”,

“objectType”: “User”,

“signInName”: null,

“userPrincipalName”: “fcampo_hotmail.com#EXT#@salondelmal.onmicrosoft.com”

}

]

az>> az vmss create –name lililabdc -g myazurelab001 -l eastus2 –image Win2012R2Datacenter –admin-username liliana –admin-password C0l0mbia2o17$ –vnet-name vnet001 –subnet snet001

{

“vmss”: {

“overprovision”: true,

“provisioningState”: “Succeeded”,

“singlePlacementGroup”: true,

“uniqueId”: “d3e3205d-4028-4cd1-b6f7-95e6ab30686d”,

“upgradePolicy”: {

“mode”: “Manual”

},

“virtualMachineProfile”: {

“networkProfile”: {

“networkInterfaceConfigurations”: [

{

“name”: “lilila97cNic”,

“properties”: {

“dnsSettings”: {

“dnsServers”: []

},

“enableAcceleratedNetworking”: false,

“ipConfigurations”: [

{

“name”: “lilila97cIPConfig”,

“properties”: {

“loadBalancerBackendAddressPools”: [

{

“id”: “/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/loadBalancers/lililabdcLB/backendAddressPools/lililabdcLBBEPool”,

“resourceGroup”: “myazurelab001”

}

],

“loadBalancerInboundNatPools”: [

{

“id”: “/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/loadBalancers/lililabdcLB/inboundNatPools/lililabdcLBNatPool”,

“resourceGroup”: “myazurelab001”

}

],

“privateIPAddressVersion”: “IPv4”,

“subnet”: {

“id”: “/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/virtualNetworks/vnet001/subnets/snet001”,

“resourceGroup”: “myazurelab001”

}

}

}

],

“primary”: true

}

}

]

},

“osProfile”: {

“adminUsername”: “liliana”,

“computerNamePrefix”: “lilila97c”,

“secrets”: [],

“windowsConfiguration”: {

“enableAutomaticUpdates”: true,

“provisionVMAgent”: true

}

},

“storageProfile”: {

“imageReference”: {

“offer”: “WindowsServer”,

“publisher”: “MicrosoftWindowsServer”,

“sku”: “2012-R2-Datacenter”,

“version”: “latest”

},

“osDisk”: {

“caching”: “ReadWrite”,

“createOption”: “FromImage”,

“managedDisk”: {

“storageAccountType”: “Standard_LRS”

}

}

}

}

}

}

az>> az vmss list-instance-connection-info -g myazurelab001 –name lililabdc

{

“instance 0”: “52.179.172.137:50000”,

“instance 2”: “52.179.172.137:50002”

}

az>>

Anuncios