Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/command_modules/azure-cli-container/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

0.3.6
+++++
* Allow using only subnet ID to setup a virtual network for the container group
* Add '--vnet-resource-group' to allow creating vnet and subnet in seperate resource group from the container group

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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


0.3.5
+++++
* Minor changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def load_arguments(self, _):

with self.argument_context('container create', arg_group='Network') as c:
c.argument('network_profile', network_profile_type)
c.argument('vnet_resource_group', help='The name of the resource group for the vnet and subnet.')
c.argument('vnet_name', help='The name of the VNET when creating a new one or referencing an existing one.')
c.argument('vnet_address_prefix', help='The IP address prefix to use when creating a new VNET in CIDR format.')
c.argument('subnet', options_list=['--subnet'], validator=validate_subnet, help='The name of the subnet when creating a new VNET or referencing an existing one. Can also reference an existing subnet by ID.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def create_container(cmd,
azure_file_volume_mount_path=None,
log_analytics_workspace=None,
log_analytics_workspace_key=None,
vnet_resource_group=None,
vnet_name=None,
vnet_address_prefix='10.0.0.0/16',
subnet=None,
Expand Down Expand Up @@ -178,8 +179,8 @@ def create_container(cmd,
environment_variables = environment_variables or secure_environment_variables

# Set up VNET, subnet and network profile if needed
if subnet and vnet_name and not network_profile:
network_profile = _get_vnet_network_profile(cmd, location, resource_group_name, vnet_name, vnet_address_prefix, subnet, subnet_address_prefix)
if subnet and not network_profile:
network_profile = _get_vnet_network_profile(cmd, location, vnet_resource_group or resource_group_name, vnet_name, vnet_address_prefix, subnet, subnet_address_prefix)

cg_network_profile = None
if network_profile:
Expand Down Expand Up @@ -247,6 +248,7 @@ def _get_vnet_network_profile(cmd, location, resource_group_name, vnet_name, vne
subnet = _get_resource(ncf.subnets, resource_group_name, vnet_name, subnet_name)
# For an existing subnet, validate and add delegation if needed
if subnet:
logger.info('Using existing subnet "%s"', subnet_name)
for endpoint in (subnet.service_endpoints or []):
if endpoint.service != "Microsoft.ContainerInstance":
raise CLIError("Can not use subnet with existing service links other than 'Microsoft.ContainerInstance'.")
Expand All @@ -260,6 +262,7 @@ def _get_vnet_network_profile(cmd, location, resource_group_name, vnet_name, vne

network_profile = _get_resource(ncf.network_profiles, resource_group_name, default_network_profile_name)
if network_profile:
logger.info('Using existing network profile "%s"', default_network_profile_name)
return network_profile.id

# Create new subnet and Vnet if not exists
Expand All @@ -268,6 +271,7 @@ def _get_vnet_network_profile(cmd, location, resource_group_name, vnet_name, vne
'AddressSpace', resource_type=ResourceType.MGMT_NETWORK)
vnet = _get_resource(ncf.virtual_networks, resource_group_name, vnet_name)
if not vnet:
logger.info('Creating new vnet "%s" in resource group "%s"', vnet_name, resource_group_name)
ncf.virtual_networks.create_or_update(resource_group_name,
vnet_name,
VirtualNetwork(name=vnet_name,
Expand All @@ -279,6 +283,7 @@ def _get_vnet_network_profile(cmd, location, resource_group_name, vnet_name, vne
address_prefix=subnet_address_prefix,
delegations=[aci_delegation])

logger.info('Creating new subnet "%s" in resource group "%s"', subnet_name, resource_group_name)
subnet = ncf.subnets.create_or_update(resource_group_name, vnet_name, subnet_name, subnet).result()

NetworkProfile, ContainerNetworkInterfaceConfiguration, IPConfigurationProfile = cmd.get_models('NetworkProfile',
Expand All @@ -299,6 +304,7 @@ def _get_vnet_network_profile(cmd, location, resource_group_name, vnet_name, vne
)]
)

logger.info('Creating network profile "%s"', default_network_profile_name)
network_profile = ncf.network_profiles.create_or_update(resource_group_name, default_network_profile_name, network_profile).result()

return network_profile.id
Expand Down
2 changes: 1 addition & 1 deletion src/command_modules/azure-cli-container/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
logger.warn("Wheel is not available, disabling bdist_wheel hook")
cmdclass = {}

VERSION = "0.3.5"
VERSION = "0.3.6"

CLASSIFIERS = [
'Development Status :: 4 - Beta',
Expand Down