Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Compute] vm create --count mode, support vnet and subnet configuration #17660

Merged
merged 3 commits into from
Apr 15, 2021

Conversation

qwordy
Copy link
Member

@qwordy qwordy commented Apr 13, 2021

Description

Resolve #17649
Support --vnet-name, --subnet
Example (3) can work in current version of Azure CLI. Example (1) (2) will work on 5/4/2021. We need to be aware of "az vm create" does not support full functionality of vnet and subnet creation. Use "az network vnet" to create vnet and subnet if you'd like to control all configuration.
Testing Guide

(1)
# Use existing vnet and subnet.
$rg="fy"
az group create -g $rg -l eastus
az network vnet create -g $rg -n vnet --address-prefix 10.0.0.0/16
az network vnet subnet create -g $rg --vnet-name vnet -n subnet1 --address-prefixes 10.0.0.0/24
az network vnet subnet create -g $rg --vnet-name vnet -n subnet2 --address-prefixes 10.0.1.0/24
az vm create -g $rg -n vma --count 5 --image ubuntults --nsg-rule None --vnet-name vnet --subnet subnet1
az vm create -g $rg -n vmb --count 5 --image ubuntults --nsg-rule None --vnet-name vnet --subnet subnet2

(2)
# Use existing vnet and subnet in another resource group
$rg1="fy2"
$rg2="fy3"
az group create -g $rg1 -l eastus
az group create -g $rg2 -l eastus
az network vnet create -g $rg1 -n vnet --address-prefix 10.0.0.0/16 --subnet-name subnet --subnet-prefix 10.0.0.0/24
$subnetId=$(az network vnet subnet show -g $rg1 -n subnet --vnet-name vnet --query [id] -o tsv)
az vm create -g $rg2 -n vm --count 5 --image ubuntults --nsg-rule None --subnet $subnetID

(3)
# Specify address prefix
$rg="fy4"
$count="150"
az group create -g $rg -l eastus
# Will create new vnet and subnet
az vm create -g $rg -n vma --count $count --image ubuntults --nsg-rule None --vnet-address-prefix 10.0.0.0/8 --subnet-address-prefix 10.0.0.0/16
# Will use vnet and subnet created just now
az vm create -g $rg -n vmb --count $count --image ubuntults --nsg-rule None
az vm create -g $rg -n vmc --count $count --image ubuntults --nsg-rule None

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change.
[Component Name 2] az command b: Add some customer-facing feature.


This checklist is used to make sure that common guidelines for a pull request are followed.

@qwordy qwordy requested review from houk-ms and yungezz as code owners April 13, 2021 05:36
@qwordy qwordy added this to the S186 milestone Apr 14, 2021
Copy link
Contributor

@houk-ms houk-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you link your PR which supports the --count parameter here? I have no context why we need remove the lines in the validation function.

@@ -1781,9 +1782,7 @@ def _validate_count(namespace):
namespace.public_ip_address_dns_name,
namespace.storage_account,
namespace.storage_container_name,
namespace.subnet,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we remove it here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I disabled it. Now I decide to enable it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yungezz
Copy link
Member

yungezz commented Apr 14, 2021

the change itself LGTM, is there any test on --count, to expand coverage of those params?

@yungezz yungezz added the Compute az vm/vmss/image/disk/snapshot label Apr 14, 2021
@qwordy
Copy link
Member Author

qwordy commented Apr 14, 2021

the change itself LGTM, is there any test on --count, to expand coverage of those params?

I should double all vm test with only one difference "--count". I give up.

@houk-ms
Copy link
Contributor

houk-ms commented Apr 14, 2021

the change itself LGTM, is there any test on --count, to expand coverage of those params?

I should double all vm test with only one difference "--count". I give up.

At least --vnet-name and --subnet parameters should be tested with --count.

@qwordy qwordy merged commit dcf4084 into Azure:dev Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compute az vm/vmss/image/disk/snapshot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Compute] vm create, support network configuration in --count mode
3 participants