Test
Test
Next steps
Learn more about Scheduled Events
How to enable nested virtualization in an Azure VM
5/9/2019 � 5 minutes to read � Edit Online
Create a nesting capable Azure VM
NOTE
Connect to your Azure VM
Enable the Hyper-V feature on the Azure VM
Option 1: Use a PowerShell script to configure nested virtualization
Option 2: Configure nested virtualization manually
Nested virtualization is supported in several Azure virtual machine families. This
capability provides great flexibility
in supporting scenarios such as development, testing, training, and demonstration
environments.
This article steps through enabling Hyper-V on an Azure VM and configuring Internet
connectivity to that guest
virtual machine.
Create a new Windows Server 2016 Azure VM. For quick reference, all v3 virtual
machines support nested
virtualization. For a complete list of virtual machine sizes that support nesting,
check out the Azure Compute Unit
article.
Remember to choose a VM size large enough to support the demands of a guest virtual
machine. In this example,
we are using a D3_v3 size Azure VM.
You can view the regional availability of Dv3 or Ev3 series virtual machines here.
For detailed instructions on creating a new virtual machine, see Create and Manage
Windows VMs with the Azure PowerShell
module
Create a remote desktop connection to the virtual machine.
1. Click the Connect button on the virtual machine properties. A Remote Desktop
Protocol file (.rdp file) is
created and downloaded.
2. To connect to your VM, open the downloaded RDP file. If prompted, click Connect.
On a Mac, you need an
RDP client such as this Remote Desktop Client from the Mac App Store.
3. Enter the user name and password you specified when creating the virtual
machine, then click Ok.
4. You may receive a certificate warning during the sign-in process. Click Yes or
Continue to proceed with the
connection.
You can configure these settings manually or we have provided a PowerShell script
to automate the configuration.
A PowerShell script to enable nested virtualization on a Windows Server 2016 host
is available on GitHub. The
script checks pre-requisites and then configures nested virtualization on the Azure
VM. A restart of the Azure VM
is necessary to complete the configuration. This script may work in other
environments but is not guaranteed.
Check out the Azure blog post with a live video demonstration on nested
virtualization running on Azure!
https://aka.ms/AzureNVblog.
Set up internet connectivity for the guest virtual machine
Create a NAT virtual network switch
Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart
WARNING
1. On the Azure VM, open PowerShell as an Administrator.
2. Enable the Hyper-V feature and Management Tools.
This command restarts the Azure VM. You will lose your RDP connection during the
restart process.
3. After the Azure VM restarts, reconnect to your VM using RDP.
Create a new virtual network adapter for the guest virtual machine and configure a
NAT Gateway to enable
Internet connectivity.
New-VMSwitch -Name "InternalNAT" -SwitchType Internal
Get-NetAdapter
NOTE
1. On the Azure VM, open PowerShell as an Administrator.
2. Create an internal switch.
3. View the properties of the switch and note the ifIndex for the new adapter.
Take note of the "ifIndex" for the virtual switch you just created.
4. Create an IP address for the NAT Gateway.
In order to configure the gateway, you need some information about your network:
IPAddress - The NAT Gateway IP specifies the IPv4 or IPv6 address to use as the
default gateway address
for the virtual network subnet. The generic form is a.b.c.1 (for example,
"192.168.0.1"). While the final
position doesn�t have to be .1, it usually is (based on prefix length). Typically
you should use an RFC 1918
private network address space.
PrefixLength - The subnet prefix length defines the local subnet size (subnet
mask). The subnet prefix length
will be an integer value between 0 and 32. 0 would map the entire internet, 32
would only allow one
mapped IP. Common values range from 24 to 12 depending on how many IPs need to be
attached to the
Create the NAT network
New-NetNat -Name "InternalNat" -InternalIPInterfaceAddressPrefix 192.168.0.0/24
Create the guest virtual machine
New-NetIPAddress -IPAddress 192.168.0.1 -PrefixLength 24 -InterfaceIndex 13
NAT. A common PrefixLength is 24 -- this is a subnet mask of 255.255.255.0.
InterfaceIndex - ifIndex is the interface index of the virtual switch created in
the previous step.
In order to configure the gateway, you will need to provide information about the
network and NAT Gateway:
Name - This is the name of the NAT network.
InternalIPInterfaceAddressPrefix - The NAT subnet prefix describes both the NAT
Gateway IP prefix from above
as well as the NAT Subnet Prefix Length from above. The generic form will be
a.b.c.0/NAT Subnet Prefix Length.
In PowerShell, create a new NAT network.
NOTE
1. Open Hyper-V Manager and create a new virtual machine. Configure the virtual
machine to use the new
Internal network you created.
2. Install an operating system on the guest virtual machine.
You need installation media for an operating system to install on the VM. In this
case we are using Windows 10
Enterprise.
Assign an IP address to the guest virtual machine
Option 1: Configure DHCP to dynamically assign an IP address to the guest virtual
machine
Install DCHP Server on the Azure VM
Configure a new DHCP scope
Option 2: Manually set a static IP address on the guest virtual machine
Test connectivity in guest virtual machine
You can assign an IP address to the guest virtual machine either by manually
setting a static IP address on the
guest virtual machine or configuring DHCP on the Azure VM to assign the IP address
dynamically.
Follow the steps below to configure DHCP on the host virtual machine for dynamic
address assignment.
1. Open Server Manager. On the Dashboard, click Add roles and features. The Add
Roles and Features
Wizard appears.
2. In wizard, click Next until the Server Roles page.
3. Click to select the DHCP Server checkbox, click Add Features, and then click
Next until you complete the
wizard.
4. Click Install.
1. Open DHCP Manager.
2. In the navigation pane, expand the server name, right-click IPv4, and click New
Scope. The New Scope
Wizard appears, click Next.
3. Enter a Name and Description for the scope and click Next.
4. Define an IP Range for your DCHP Server (for example, 192.168.0.100 to
192.168.0.200).
5. Click Next until the Default Gateway page. Enter the IP Address you created
earlier (for example,
192.168.0.1) as the Default Gateway, then click Add.
6. Click Next until the wizard completes, leaving all default values, then click
Finish.
If you did not configure DHCP to dynamically assign an IP address to the guest
virtual machine, follow these steps
to set a static IP address.
1. On the Azure VM, open PowerShell as an Administrator.
2. Right-click the guest virtual machine and click Connect.
3. Log on to the guest virtual machine.
4. On the guest virtual machine, open the Network and Sharing Center.
5. Configure the network adapter for an address within the range of the NAT network
you created in the
previous section.
In this example you will use an address in the 192.168.0.0/24 range.
In the guest virtual machine, open your browser and navigate to a web page.
Set up intranet connectivity for the guest virtual machine
For instructions on how to enable transparent connectivity between Guest VMs and
Azure VMs, please reference
this document.
Prepay for Virtual Machines with Azure Reserved VM
Instances (RI)
4/19/2019 � 6 minutes to read � Edit Online
Determine the right VM size before you buy
Use reservation recommendations
Classic VMs and cloud services
Analyze your usage information
Prepay for virtual machines and save money with Azure Reserved Virtual Machine (VM)
Instances. For more
information, see Azure Reserved VM Instances offering.
You can buy a Reserved VM Instance in the Azure portal. To buy an instance:
You must be in an Owner role for at least one Enterprise or Pay-As-You-Go
subscription.
For Enterprise subscriptions, Add Reserved Instances must be enabled in the EA
portal. Or, if that setting is
disabled, you must be an EA Admin on the subscription.
For the Cloud Solution Provider (CSP) program, only the admin agents or sales
agents can buy reservations.
The reservation discount is applied automatically to the number of running virtual
machines that match the
reservation scope and attributes. You can update the scope of the reservation
through Azure portal, PowerShell,
CLI, or through the API.
Before you buy a reservation, you should determine the size of the VM that you
need. The following sections will
help you determine the right VM size.
You can use reservation recommendations to help determine the reservations you
should purchase.
Purchase recommendations and recommended quantity are show when you purchase a VM
reserved instance
in the Azure portal.
Azure Advisor provides purchase recommendations for individual subscriptions.
You can use the APIs to get purchase recommendations for both shared scope and
single subscription scope.
For more information, see Reserved instance purchase recommendation APIs for
enterprise customers.
For EA customers, purchase recommendations for shared and single subscription
scopes are available with the
Azure Consumption Insights Power BI content pack.
Virtual machine reserved instances automatically apply to both classic VMs and
cloud services when instance size
flexibility is enabled. There aren't any special SKUs for classic VMs or cloud
services. The same VM SKUs apply to
them.
For example, you might convert your classic VMs or cloud services to Azure Resource
Manager-based VMs. In this
example, the reservation discount automatically applies to matching VMs. There's no
need to exchange an existing
reserved instance - it automatically applies.
You should analyze your usage information to help determine which reservations you
should purchase.
Usage data is available in the usage file and APIs. Use them together to determine
which reservation to purchase.
You should check for VM instances that have high usage on daily basis to determine
the quantity of reservations to
purchase.
Avoid the Meter subcategory and Product fields in usage data. They don't
distinguish between VM sizes that use
Purchase restriction considerations
Buy a Reserved VM Instance
premium storage. If you use these fields to determine the VM size for reservation
purchase, you may buy the
wrong size. Then you won't get the reservation discount you expect. Instead, refer
to the AdditionalInfo field in
your usage file or usage API to determine the correct VM size.
Reserved VM Instances are available for most VM sizes with some exceptions.
Reservation discounts don't apply
for the following VMs:
VM series - A-series, Av2-series, or G-series.
VMs in preview - Any VM-series or size that is in preview.
Clouds - Reservations aren't available for purchase in Germany or China regions.
Insufficient quota - A reservation that is scoped to a single subscription must
have vCPU quota available
in the subscription for the new RI. For example, if the target subscription has a
quota limit of 10 vCPUs for
D-Series, then you can't buy a reservation for 11 Standard_D1 instances. The quota
check for reservations
includes the VMs already deployed in the subscription. For example, if the
subscription has a quota of 10
vCPUs for D-Series and has two standard_D1 instances deployed, then you can buy a
reservation for 10
standard_D1 instances in this subscription. You can create quote increase request
to resolve this issue.
Capacity restrictions - In rare circumstances, Azure limits the purchase of new
reservations for subset of
VM sizes, due to low capacity in a region.
FIELD DESCRIPTION
Name The name of this reservation.
Subscription The subscription used to pay for the reservation. The
payment method on the subscription is charged the
upfront costs for the reservation. The subscription type
must be an enterprise agreement (offer numbers: MSAZR-
0017P or MS-AZR-0148P) or Pay-As-You-Go (offer
numbers: MS-AZR-0003P or MS-AZR-0023P). For an
enterprise subscription, the charges are deducted from the
enrollment's monetary commitment balance or charged as
overage. For Pay-As-You-Go subscription, the charges are
billed to the credit card or invoice payment method on the
subscription.
1. Sign in to the Azure portal.
2. Select All services > Reservations.
3. Select Add to purchase a new reservation.
4. Fill in the required fields. Running VM instances that match the attributes you
select qualify to get the
reservation discount. The actual number of your VM instances that get the discount
depend on the scope
and quantity selected.
Change a reservation after purchase
Scope The reservation�s scope can cover one subscription or
multiple subscriptions (shared scope). If you select:
Region The Azure region that�s covered by the reservation.
VM Size The size of the VM instances.
Optimize for VM instance size flexibility applies the reservation discount
to other VMs in the same VM size group. Capacity priority
prioritizes data center capacity for your deployments. This
offers additional confidence in your ability to launch the
VM instances when you need them. Capacity priority is
only available when the reservation scope is single
subscription.
Term One year or three years.
Quantity The number of instances being purchased within the
reservation. The quantity is the number of running VM
instances that can get the billing discount. For example, if
you are running 10 Standard_D2 VMs in the East US, then
you would specify quantity as 10 to maximize the benefit
for all running machines.
FIELD DESCRIPTION
Single subscription - The reservation discount is
applied to VMs in this subscription.
Shared - The reservation discount is applied to
VMs running in any subscriptions within your
billing context. For enterprise customers, the
shared scope is the enrollment and includes all
subscriptions within the enrollment. For Pay-As-
You-Go customers, the shared scope is all Pay-As-
You-Go subscriptions created by the account
administrator.
You can make the following types of changes to a reservation after purchase:
Update reservation scope
Instance size flexibility (if applicable)
Ownership
You can also split a reservation into smaller chunks and merge already split
reservations. None of the changes
cause a new commercial transaction or change the end date of the reservation.
You cannot make the following types of changes after purchase, directly:
An existing reservation�s region
SKU
Quantity
Duration
However, you can exchange a reservation if you want to make changes.
Cancellations and exchanges
Need help? Contact us.
Next steps
If you need to cancel your reservation, there may be a 12% early termination fee.
Refunds are based on the lowest
price of either your purchase price or the current price of the reservation.
Refunds are limited to $50,000 per year.
The refund you receive is the remaining pro-rated balance minus the 12% early
termination fee. To request a
cancellation, go to the reservation in the Azure portal and select Refund to create
a support request.
If you need to change your Reserved VM Instances reservation to another region, VM
size group, or term, you can
exchange it for another reservation that's of equal or greater value. The term
start date for the new reservation
doesn't carry over from the exchanged reservation. The 1 or 3-year term starts from
when you create the new
reservation. To request an exchange, go to the reservation in the Azure portal, and
select Exchange to create a
support request.
For more information about how to exchange or refund reservations, see Reservation
exchanges and refunds.
If you have questions or need help, create a support request.
To learn how to manage a reservation, see Manage Azure Reservations.
To learn more about Azure Reservations, see the following articles:
What are Azure Reservations?
Manage Reservations in Azure
Understand how the reservation discount is applied
Understand reservation usage for your Pay-As-You-Go subscription
Understand reservation usage for your Enterprise enrollment
Windows software costs not included with reservations
Azure Reservations in Partner Center Cloud Solution Provider (CSP) program
What are Azure Reservations?
4/22/2019 � 5 minutes to read � Edit Online
Why buy a reservation?
Charges covered by reservation
Who's eligible to purchase a reservation?
Reservation scope
Azure Reservations help you save money by pre-paying for one-year or three-years of
virtual machines, SQL
Database compute capacity, Azure Cosmos DB throughput, or other Azure resources.
Pre-paying allows you to get
a discount on the resources you use. Reservations can significantly reduce your
virtual machine, SQL database
compute, Azure Cosmos DB, or other resource costs up to 72% on pay-as-you-go
prices. Reservations provide a
billing discount and don't affect the runtime state of your resources.
You can buy a reservation in the Azure portal.
If you have virtual machines, Azure Cosmos DB, or SQL databases that run for long
periods of time, buying a
reservation gives you the most cost-effective option. For example, when you
continuously run four instances of a
service without a reservation, you're charged at pay-as-you-go rates. If you buy a
reservation for those resources,
you immediately get the reservation discount. The resources are no longer charged
at the pay-as-you-go rates.
Service plans:
Reserved Virtual Machine Instance: A reservation only covers the virtual machine
compute costs. It doesn't
cover additional software, networking, or storage charges.
Azure Cosmos DB reserved capacity: A reservation covers throughput provisioned for
your resources. It
doesn't cover the storage and networking charges.
SQL Database reserved vCore: Only the compute costs are included with a
reservation. The license is billed
separately.
For Windows virtual machines and SQL Database, you can cover the licensing costs
with Azure Hybrid Benefit.
To buy a plan, you must have a subscription owner role in an Enterprise (MS-AZR-
0017P or MS-AZR-0148P) or
Pay-As-You-Go subscription (MS-AZR-003P or MS-AZR-0023P). Cloud solution providers
can use the Azure
portal orPartner Centerto purchase Azure Reservations.
EA customers can limit purchases to EA admins by disabling the Add Reserved
Instances option in EA Portal. EA
admins must be a subscription owner for at least one EA subscription to purchase a
reservation. The option is
useful for enterprises that want a centralized team to purchase reservations for
different cost centers. After the
purchase, centralized teams can add cost center owners to the reservations. Owners
can then scope the reservation
to their subscriptions. The central team doesn't need to have subscription owner
access where the reservation is
purchased.
A reservation discount only applies to resources associated with Enterprise, Pay-
As-You-Go, or CSP subscription
types.
A reservation scope determines the resources to which the reservation discount
applies. A reservation scope can
have following values:
Discounted subscription and offer types
How is a reservation billed?
How reservation discount is applied
When the reservation term expires
Shared scope - The reservation discount is applied to the matching resources in
eligible subscriptions within the
billing context.
For Enterprise Agreement customers, the billing context is the enrollment. For Pay-
as-you-go customers, the
billing scope is all eligible subscriptions created by the account administrator.
Single subscription - The reservation discount is applied to the matching resources
in the selected subscription.
You can update the scope after you purchase a reservation.
Reservation discounts apply to the following eligible subscriptions and offer
types.
Enterprise agreement (offer numbers: MS-AZR-0017P or MS-AZR-0148P)
Pay-As-You-Go (offer numbers: MS-AZR-0003P or MS-AZR-0023P)
CSP subscriptions
Resources that run in a subscription with other offer types don't receive the
reservation discount.
The reservation is charged to the payment method tied to the subscription. If you
have an Enterprise subscription,
the reservation cost is deducted from your monetary commitment balance. If your
monetary commitment balance
doesn't cover the cost of the reservation, you're billed the overage. If you have a
Pay-As-You-Go subscription, the
credit card you have on your account is billed immediately. If you're billed by
invoice, you see the charges on your
next invoice.
The reservation discount applies to the resource usage matching the attributes you
select when you buy the
reservation. The attributes include the scope where the matching VMs, SQL
databases, Azure Cosmos DB, or other
resources run. For example, if you want a reservation discount for four Standard D2
virtual machines in the West
US region, then select the subscription where the VMs are running.
A reservation discount is "use-it-or-lose-it". If you don't have matching resources
for any hour, then you lose a
reservation quantity for that hour. You can't carry forward unused reserved hours.
When you shut down a resource, the reservation discount automatically applies to
another matching resource in
the specified scope. If no matching resources are found in the specified scope,
then the reserved hours are lost.
For example, you might later create a resource and have a matching reservation that
is underutilized. In this
example, the reservation discount automatically applies to the new matching
resource.
If the virtual machines are running in different subscriptions within your
enrollment/account, then select the scope
as shared. Shared scope allows the reservation discount to be applied across
subscriptions. You can change the
scope after you buy a reservation. For more information, see Manage Azure
Reservations.
A reservation discount only applies to resources associated with Enterprise, Pay-
As-You-Go, or CSP subscription
types. Resources that run in a subscription with other offer types don't receive
the reservation discount.
At the end of the reservation term, the billing discount expires, and the virtual
machine, SQL database, Azure
Cosmos DB, or other resource is billed at the pay-as-you go price. Azure
Reservations don't auto-renew. To
continue getting the billing discount, you must buy a new reservation for eligible
services and software.
Discount applies to different sizes
Need help? Contact us.
Next steps
When you buy a reservation, the discount can apply to other instances with
attributes that are within the same size
group. This feature is known as instance size flexibility. The flexibility of the
discount coverage depends on the type
of reservation and the attributes you pick when you buy the reservation.
Service plans:
Reserved VM Instances: When you buy the reservation and select Optimized for:
instance size flexibility,
the discount coverage depends on the VM size you select. The reservation can apply
to the virtual machines
(VMs) sizes in the same size series group. For more information, see Virtual
machine size flexibility with
Reserved VM Instances.
SQL Database reserved capacity: The discount coverage depends on the performance
tier you pick. For more
information, see Understand how an Azure reservation discount is applied.
Azure Cosmos DB reserved capacity: The discount coverage depends on the provisioned
throughput. For more
information, see Understand how an Azure Cosmos DB reservation discount is applied.
If you have questions or need help, create a support request.
Learn more about Azure Reservations with the following articles:
Manage Azure Reservations
Understand reservation usage for your Pay-As-You-Go subscription
Understand reservation usage for your Enterprise enrollment
Windows software costs not included with reservations
Azure Reservations in Partner Center Cloud Solution Provider (CSP) program
Learn more about reservations for service plans:
Virtual Machines with Azure Reserved VM Instances
Azure Cosmos DB resources with Azure Cosmos DB reserved capacity
SQL Database compute resources with Azure SQL Database reserved capacity Learn more
about
reservations for software plans:
Red Hat software plans from Azure Reservations
SUSE software plans from Azure Reservations
Virtual machine size flexibility with Reserved VM
Instances
2/28/2019 � 5 minutes to read � Edit Online
Examples
B-series
SIZE RATIO
Standard_B1s 1
Standard_B2s 4
With a reserved virtual machine instance that's optimized for instance size
flexibility, the reservation you buy can
apply to the virtual machines (VMs) sizes in the same size series group. For
example, if you buy a reservation for a
VM size that's listed in the DSv2-series table, like Standard_DS5_v2, the
reservation discount can apply to the other
four sizes that are listed in that same table:
Standard_DS1_v2
Standard_DS2_v2
Standard_DS3_v2
Standard_DS4_v2
But that reservation discount doesn't apply to VMs sizes that are listed in
different tables, like what's in the DSv2-
series high memory table: Standard_DS11_v2, Standard_DS12_v2, and so on.
Within the size series group, the number of VMs the reservation discount applies to
depends on the VM size you
pick when you buy a reservation. It also depends on the sizes of the VMs that you
have running. The ratio column
that's listed in the following tables compares the relative footprint for each VM
size in that group. Use the ratio
value to calculate how the reservation discount applies to the VMs you have
running.
The following examples use the sizes and ratios in the DSv2-series table.
You buy a reserved VM instance with the size Standard_DS4_v2 where the ratio or
relative footprint compared to
the other sizes in that series is 8.
Scenario 1: Run eight Standard_DS1_v2 sized VMs with a ratio of 1. Your reservation
discount applies to all
eight of those VMs.
Scenario 2: Run two Standard_DS2_v2 sized VMs with a ratio of 2 each. Also run a
Standard_DS3_v2 sized VM
with a ratio of 4. The total footprint is 2+2+4=8. So your reservation discount
applies to all three of those VMs.
Scenario 3: Run one Standard_DS5_v2 with a ratio of 16. Your reservation discount
applies to half that VM's
compute cost.
The following sections show what sizes are in the same size series group when you
buy a reserved VM instance
optimized for instance size flexibility.
For more information, see B-series burstable virtual machine sizes.
B-series high memory
SIZE RATIO
Standard_B1ms 1
Standard_B2ms 4
Standard_B4ms 8
Standard_B8ms 16
D-series
SIZE RATIO
Standard_D1 1
Standard_D2 2
Standard_D3 4
Standard_D4 8
D-series high memory
SIZE RATIO
Standard_D11 1
Standard_D12 2
Standard_D13 4
Standard_D14 8
Ds-series
SIZE RATIO
Standard_DS1 1
Standard_DS2 2
Standard_DS3 4
For more information, see B-series burstable virtual machine sizes.
For more information, see Previous generations of virtual machine sizes.
For more information, see Previous generations of virtual machine sizes.
Standard_DS4 8
SIZE RATIO
Ds-series high memory
SIZE RATIO
Standard_DS11 1
Standard_DS12 2
Standard_DS13 4
Standard_DS14 8
DSv2-series
SIZE RATIO
Standard_DS1_v2 1
Standard_DS2_v2 2
Standard_DS3_v2 4
Standard_DS4_v2 8
Standard_DS5_v2 16
DSv2-series high memory
SIZE RATIO
Standard_DS11_v2 1
Standard_DS11-1_v2 1
Standard_DS12_v2 2
Standard_DS12-1_v2 2
Standard_DS12-2_v2 2
Standard_DS13_v2 4
For more information, see Previous generations of virtual machine sizes.
For more information, see Previous generations of virtual machine sizes.
For more information, see Previous generations of virtual machine sizes.
Standard_DS13-2_v2 4
Standard_DS13-4_v2 4
Standard_DS14_v2 8
Standard_DS14-4_v2 8
Standard_DS14-8_v2 8
Standard_DS15_v2 10
SIZE RATIO
DSv3-series
SIZE RATIO
Standard_D2s_v3 1
Standard_D4s_v3 2
Standard_D8s_v3 4
Standard_D16s_v3 8
Standard_D32s_v3 16
Standard_D64s_v3 32
Dv2-series
SIZE RATIO
Standard_D1_v2 1
Standard_D2_v2 2
Standard_D3_v2 4
Standard_D4_v2 8
Standard_D5_v2 16
Dv2-series high memory
For more information, see Previous generations of virtual machine sizes.
For more information, see General purpose virtual machine sizes.
For more information, see Previous generations of virtual machine sizes.
SIZE RATIO
Standard_D11_v2 1
Standard_D12_v2 2
Standard_D13_v2 4
Standard_D14_v2 8
Standard_D15_v2 10
Dv3-series
SIZE RATIO
Standard_D2_v3 1
Standard_D4_v3 2
Standard_D8_v3 4
Standard_D16_v3 8
Standard_D32_v3 16
Standard_D64_v3 32
ESv3-series
SIZE RATIO
Standard_E2s_v3 1
Standard_E4s_v3 2
Standard_E4-2s_v3 2
Standard_E8s_v3 4
Standard_E8-2s_v3 4
Standard_E8-4s_v3 4
Standard_E16s_v3 8
Standard_E16-4s_v3 8
For more information, see Previous generations of virtual machine sizes.
For more information, see General purpose virtual machine sizes.
Standard_E16-8s_v3 8
Standard_E20s_v3 10
Standard_E32s_v3 16
Standard_E32-8s_v3 16
Standard_E32-16s_v3 16
Standard_E64s_v3 28.8
Standard_E64-16s_v3 28.8
Standard_E64-32s_v3 28.8
SIZE RATIO
Ev3-series
SIZE RATIO
Standard_E2_v3 1
Standard_E4_v3 2
Standard_E8_v3 4
Standard_E16_v3 8
Standard_E20_v3 10
Standard_E32_v3 16
Standard_E64_v3 32
F-series
SIZE RATIO
Standard_F1 1
Standard_F2 2
Standard_F4 4
Standard_F8 8
For more information, see Memory optimized virtual machine sizes.
For more information, see Memory optimized virtual machine sizes.
Standard_F16 16
SIZE RATIO
FS-series
SIZE RATIO
Standard_F1s 1
Standard_F2s 2
Standard_F4s 4
Standard_F8s 8
Standard_F16s 16
Fsv2-series
SIZE RATIO
Standard_F2s_v2 1
Standard_F4s_v2 2
Standard_F8s_v2 4
Standard_F16s_v2 8
Standard_F32s_v2 16
Standard_F64s_v2 32
Standard_F72s_v2 36
H-series
SIZE RATIO
Standard_H8 1
Standard_H16 2
For more information, see Previous generations of virtual machine sizes.
For more information, see Previous generations of virtual machine sizes.
For more information, see Compute optimized virtual machine sizes.
For more information, see High performance compute VM sizes.
H-series high memory
SIZE RATIO
Standard_H8m 1
Standard_H16m 2
Ls-series
SIZE RATIO
Standard_L4s 1
Standard_L8s 2
Standard_L16s 4
Standard_L32s 8
M-series
SIZE RATIO
Standard_M64s 1
Standard_M128s 2
M-series fractional
SIZE RATIO
Standard_M16s 1
Standard_M32s 2
M-series fractional high memory
SIZE RATIO
Standard_M8ms 1
Standard_M8-2ms 1
For more information, see High performance compute VM sizes.
For more information, see Storage optimized virtual machine sizes.
For more information, see Memory optimized virtual machine sizes.
For more information, see Memory optimized virtual machine sizes.
Standard_M8-4ms 1
Standard_M16ms 2
Standard_M16-4ms 2
Standard_M16-8ms 2
Standard_M32ms 4
Standard_M32-8ms 4
Standard_M32-16ms 4
SIZE RATIO
M-series fractional large
SIZE RATIO
Standard_M32ls 1
Standard_M64ls 2
M-series high memory
SIZE RATIO
Standard_M64ms 1
Standard_M64-16ms 1
Standard_M64-32ms 1
Standard_M128ms 2
Standard_M128-32ms 2
Standard_M128-64ms 2
NC-series
SIZE RATIO
Standard_NC6 1
For more information, see Memory optimized virtual machine sizes.
For more information, see Memory optimized virtual machine sizes.
For more information, see Memory optimized virtual machine sizes.
Standard_NC12 2
Standard_NC24 4
SIZE RATIO
NCv2-series
SIZE RATIO
Standard_NC6s_v2 1
Standard_NC12s_v2 2
Standard_NC24s_v2 4
NCv3-series
SIZE RATIO
Standard_NC6s_v3 1
Standard_NC12s_v3 2
Standard_NC24s_v3 4
ND-series
SIZE RATIO
Standard_ND6s 1
Standard_ND12s 2
Standard_ND24s 4
NV-series
SIZE RATIO
Standard_NV6 1
Standard_NV12 2
For more information, see GPU optimized virtual machine sizes.
For more information, see GPU optimized virtual machine sizes.
For more information, see GPU optimized virtual machine sizes.
For more information, see GPU optimized virtual machine sizes.
Standard_NV24 4
SIZE RATIO
For more information, see GPU optimized virtual machine sizes.
Shared Image Gallery overview
5/6/2019 � 15 minutes to read � Edit Online
RESOURCE DESCRIPTION
Managed image A basic image that can be used alone or used to create an
image version in an image gallery. Managed images are
created from generalized VMs. A managed image is a special
type of VHD that can be used to make multiple VMs and can
now be used to create shared image versions.
Image gallery Like the Azure Marketplace, an image gallery is a repository
for managing and sharing images, but you control who has
access.
Image definition Images are defined within a gallery and carry information
about the image and requirements for using it within your
organization. You can include information like whether the
image is Windows or Linux, minimum and maximum memory
requirements, and release notes. It is a definition of a type of
image.
Image version An image version is what you use to create a VM when
using a gallery. You can have multiple versions of an image as
needed for your environment. Like a managed image, when
you use an image version to create a VM, the image version
is used to create new disks for the VM. Image versions can be
used multiple times.
Shared Image Gallery is a service that helps you build structure and organization
around your managed images.
Shared Image Galleries provide:
Managed global replication of images.
Versioning and grouping of images for easier management.
Highly available images with Zone Redundant Storage (ZRS) accounts in regions that
support Availability
Zones. ZRS offers better resilience against zonal failures.
Sharing across subscriptions, and even between Active Directory (AD) tenants, using
RBAC.
Scaling your deployments with image replicas in each region.
Using a Shared Image Gallery you can share your images to different users, service
principals, or AD groups
within your organization. Shared images can be replicated to multiple regions, for
quicker scaling of your
deployments.
A managed image is a copy of either a full VM (including any attached data disks)
or just the OS disk, depending
on how you create the image. When you create a VM from the image, a copy of the
VHDs in the image are used
to create the disks for the new VM. The managed image remains in storage and can be
used over and over again
to create new VMs.
If you have a large number of managed images that you need to maintain and would
like to make them available
throughout your company, you can use a Shared Image Gallery as a repository that
makes it easy to share your
images.
The Shared Image Gallery feature has multiple resource types:
Image definitions
IMAGE DEFINITION PUBLISHER OFFER SKU
myImage1 Contoso Finance Backend
myImage2 Contoso Finance Frontend
myImage3 Testing Finance Frontend
Image definitions are a logical grouping for versions of an image. The image
definition holds information about
why the image was created, what OS it is for, and information about using the
image. An image definition is like a
plan for all of the details around creating a specific image. You don't deploy a VM
from an image definition, but
from the image version created from the definition.
There are three parameters for each image definition that are used in combination -
Publisher, Offer and SKU.
These are used to find a specific image definition. You can have image versions
that share one or two, but not all
three values. For example, here are three image definitions and their values:
All three of these have unique sets of values. The format is similar to how you can
currently specify publisher,
offer, and SKU for Azure Marketplace images in Azure PowerShell to get the latest
version of a Marketplace
image. Each image definition needs to have a unique set of these values.
The following are other parameters that can be set on your image definition so that
you can more easily track
your resources:
Operating system state - You can set the OS state to generalized or specialized,
but only generalized is
currently supported. Images must be created from VMs that have been generalized
using Sysprep for
Windows or waagent -deprovision for Linux.
Operating system - can be either Windows or Linux.
Description - use description to give more detailed information on why the image
definition exists. For
example, you might have an image definition for your front-end server that has the
application pre-installed.
Eula - can be used to point to an end-user license agreement specific to the image
definition.
Privacy Statement and Release notes - store release notes and privacy statements in
Azure storage and
provide a URI for accessing them as part of the image definition.
Regional Support
SOURCE REGIONS
Australia Central Central US EUAP Korea Central UK South 2
Australia Central 2 East Asia Korea South UK West
Australia East East US North Central US West Central US
Australia Southeast East US 2 North Europe West Europe
Brazil South East US 2 EUAP South Central US West India
Canada Central France Central South India West US
Canada East France South Southeast Asia West US
Central India Japan East UK North West US 2
Central US Japan West UK South
Limits
Scaling
End-of-life date - attach an end-of-life date to your image definition in order to
be able to use automation to
delete old image definitions.
Tag - you can add tags when you create your image definition. For more information
about tags, see Using
tags to organize your resources
Minimum and maximum vCPU and memory recommendations - if your image has vCPU and
memory
recommendations, you can attach that information to your image definition.
Disallowed disk types - you can provide information about the storage needs for
your VM. For example, if the
image isn't suited for standard HDD disks, you add them to the disallow list.
Source regions are listed in the table below. All public regions can be target
regions, but to replicate to Australia
Central and Australia Central 2 you need to have your subscription whitelisted. To
request whitelisting, go to:
https://www.microsoft.com/en-au/central-regions-eligibility/
There are limits, per subscription, for deploying resources using Shared Image
Galleries:
100 shared image galleries, per subscription, per region
1,000 image definitions, per subscription, per region
10,000 image versions, per subscription, per region
For more information, see Check resource usage against limits for examples on how
to check your current usage.
Shared Image Gallery allows you to specify the number of replicas you want Azure to
keep of the images. This
helps in multi-VM deployment scenarios as the VM deployments can be spread to
different replicas reducing the
chance of instance creation processing being throttled due to overloading of a
single replica.
With Shared Image Gallery, you can now deploy up to a 1,000 VM instances in a
virtual machine scale set (up
from 600 with managed images). Image replicas provide for better deployment
performance, reliability and
Make your images highly available
consistency. You can set a different replica count in each target region, based on
the scale needs for the region.
Since each replica is a deep copy of your image, this helps scale your deployments
linearly with each extra replica.
While we understand no two images or regions are the same, here�s our general
guideline on how to use replicas
in a region:
For every 20 VMs that you create concurrently, we recommend you keep one replica.
For example, if you are
creating 120 VMs concurrently using the same image in a region, we suggest you keep
at least 6 replicas of
your image.
For every scale set deployment with up to 600 instances, we recommend you keep at
least one replica. For
example, if you are creating 5 scale sets concurrently, each with 600 VM instances
using the same image in a
single region, we suggest you keep at least 5 replicas of your image.
We always recommend you to overprovision the number of replicas due to factors like
image size, content and
OS type.
Azure Zone Redundant Storage (ZRS) provides resilience against an Availability Zone
failure in the region. With
the general availability of Shared Image Gallery, you can choose to store your
images in ZRS accounts in regions
with Availability Zones.
You can also choose the account type for each of the target regions. The default
storage account type is
Standard_LRS, but you can choose Standard_ZRS for regions with Availability Zones.
Check the regional
availability of ZRS here.
Replication
Shared Image Gallery also allows you to replicate your images to other Azure
regions automatically. Each Shared
Image version can be replicated to different regions depending on what makes sense
for your organization. One
example is to always replicate the latest image in multi-regions while all older
versions are only available in 1
region. This can help save on storage costs for Shared Image versions.
The regions a Shared Image version is replicated to can be updated after creation
time. The time it takes to
replicate to different regions depends on the amount of data being copied and the
number of regions the version
is replicated to. This can take a few hours in some cases. While the replication is
happening, you can view the
status of replication per region. Once the image replication is complete in a
region, you can then deploy a VM or
scale-set using that image version in the region.
Access
SHARED WITH USER SHARED IMAGE GALLERY IMAGE DEFINITION IMAGE VERSION
Shared Image Gallery Yes Yes Yes
Image Definition No Yes Yes
Billing
As the Shared Image Gallery, Image Definition, and Image version are all resources,
they can be shared using the
built-in native Azure RBAC controls. Using RBAC you can share these resources to
other users, service principals,
and groups. You can even share access to individuals outside of the tenant they
were created within. Once a user
has access to the Shared Image version, they can deploy a VM or a Virtual Machine
Scale Set. Here is the sharing
matrix that helps understand what the user gets access to:
We recommend sharing at the Gallery level for the best experience. We do not
recommend sharing individual
image versions. For more information about RBAC, see Manage access to Azure
resources using RBAC.
Images can also be shared, at scale, even across tenants using a multi-tenant app
registration. For more
information about sharing images across tenants, see Share gallery VM images across
Azure tenants.
There is no extra charge for using the Shared Image Gallery service. You will be
charged for the following
resources:
Storage costs of storing the Shared Image versions. Cost depends on the number of
replicas of the image
version and the number of regions the version is replicated to. For example, if you
have 2 images and both are
replicated to 3 regions, then you will be changed for 6 managed disks based on
their size. For more
information, see Managed Disks pricing.
Network egress charges for replication of the first image version from the source
region to the replicated
Updating resources
SDK support
Templates
Frequently asked questions
regions. Subsequent replicas are handled within the region, so there are no
additional charges.
Once created, you can make some changes to the image gallery resources. These are
limited to:
Shared image gallery:
Description
Image definition:
Recommended vCPUs
Recommended memory
Description
End of life date
Image version:
Regional replica count
Target regions
Exclude from latest
End of life date
The following SDKs support creating Shared Image Galleries:
.NET
Java
Node.js
Python
Go
You can create Shared Image Gallery resource using templates. There are several
Azure Quickstart Templates
available:
Create a Shared Image Gallery
Create an Image Definition in a Shared Image Gallery
Create an Image Version in a Shared Image Gallery
Create a VM from Image Version
Q. How can I list all the Shared Image Gallery resources across subscriptions?
A. In order to list all the Shared Image Gallery resources across subscriptions
that you have access to on the
Azure portal, follow the steps below:
1. Open the Azure portal.
2. Go to All Resources.
3. Select all the subscriptions under which you�d like to list all the resources.
az account list -otsv --query "[].id" | xargs -n 1 az sig list --subscription
4. Look for resources of type Private gallery.
To see the image definitions and image versions, you should also select Show hidden
types.
To list all the Shared Image Gallery resources across subscriptions that you have
permissions to, use the
following command in the Azure CLI:
Q. Can I move my existing image to the shared image gallery?
A. Yes. There are 3 scenarios based on the types of images you may have.
Scenario 1: If you have a managed image, then you can create an image definition
and image version from it.
Scenario 2: If you have an unmanaged generalized image, you can create a managed
image from it, and then
create an image definition and image version from it.
Scenario 3: If you have a VHD in your local file system, then you need to upload
the VHD, create a managed
image, then you can create and image definition and image version from it.
If the VHD is of a Windows VM, see Upload a generalized VHD.
If the VHD is for a Linux VM, see Upload a VHD
Q. Can I create an image version from a specialized disk?
A. No, we do not currently support specialized disks as images. If you have a
specialized disk, you need to create a
VM from the VHD by attaching the specialized disk to a new VM. Once you have a
running VM, you need to
follow the instructions to create a managed image from the Windows VM or Linux VM.
Once you have a
generalized managed image, you can start the process to create a shared image
description and image version.
Q. Once created, can I move the Shared Image Gallery resource to a different
subscription?
A. No, you cannot move the shared image gallery resource to a different
subscription. However, you will be able
to replicate the image versions in the gallery to other regions as required.
Q. Can I replicate my image versions across clouds � Azure China 21Vianet, Azure
Germany and Azure
Government Cloud?
A. No, you cannot replicate image versions across clouds.
Q. Can I replicate my image versions across subscriptions?
A. No, you may replicate the image versions across regions in a subscription and
use it in other subscriptions
through RBAC.
Q. Can I share image versions across Azure AD tenants?
A. Yes, you can use RBAC to share to individuals across tenants. But, to share at
scale, see "Share gallery images
across Azure tenants" using PowerShell or CLI.
Q. How long does it take to replicate image versions across the target regions?
A. The image version replication time is entirely dependent on the size of the
image and the number of regions it
is being replicated to. However, as a best practice, it is recommended that you
keep the image small, and the
source and target regions close for best results. You can check the status of the
replication using the -
ReplicationStatus flag.
Q. What is the difference between source region and target region?
Next steps
A. Source region is the region in which your image version will be created, and
target regions are the regions in
which a copy of your image version will be stored. For each image version, you can
only have one source region.
Also, make sure that you pass the source region location as one of the target
regions when you create an image
version.
Q. How do I specify the source region while creating the image version?
A. While creating an image version, you can use the --location tag in CLI and the
-Location tag in PowerShell to
specify the source region. Please ensure the managed image that you are using as
the base image to create the
image version is in the same location as the location in which you intend to create
the image version. Also, make
sure that you pass the source region location as one of the target regions when you
create an image version.
Q. How do I specify the number of image version replicas to be created in each
region?
A. There are two ways you can specify the number of image version replicas to be
created in each region:
1. The regional replica count which specifies the number of replicas you want to
create per region.
2. The common replica count which is the default per region count in case regional
replica count is not specified.
To specify the regional replica count, pass the location along with the number of
replicas you want to create in that
region: �South Central US=2�.
If regional replica count is not specified with each location, then the default
number of replicas will be the
common replica count that you specified.
To specify the common replica count in CLI, use the --replica-count argument in the
az sig image-version create command.
Q. Can I create the shared image gallery in a different location than the one where
I want to create the image
definition and image version?
A. Yes, it is possible. But, as a best practice, we encourage you to keep the
resource group, shared image gallery,
image definition, and image version in the same location.
Q. What are the charges for using the Shared Image Gallery?
A. There are no charges for using the Shared Image Gallery service, except the
storage charges for storing the
image versions and network egress charges for replicating the image versions from
source region to target
regions.
Q. What API version should I use to create Shared Image Gallery, Image Definition,
Image Version, and
VM/VMSS out of the Image Version?
A. For VM and Virtual Machine Scale Set deployments using an image version, we
recommend you use API
version 2018-04-01 or higher. To work with shared image galleries, image
definitions, and image versions, we
recommend you use API version 2018-06-01. Zone Redundant Storage (ZRS) requires
version 2019-03-01 or
later.
Learn how to deploy shared images using Azure PowerShell.
Create a shared image gallery with Azure PowerShell
5/23/2019 � 8 minutes to read � Edit Online
RESOURCE DESCRIPTION
Managed image This is a basic image that can be used alone or used to create
an image version in an image gallery. Managed images are
created from generalized VMs. A managed image is a special
type of VHD that can be used to make multiple VMs and can
now be used to create shared image versions.
Image gallery Like the Azure Marketplace, an image gallery is a repository
for managing and sharing images, but you control who has
access.
Image definition Images are defined within a gallery and carry information
about the image and requirements for using it internally. This
includes whether the image is Windows or Linux, release
notes, and minimum and maximum memory requirements. It
is a definition of a type of image.
Image version An image version is what you use to create a VM when
using a gallery. You can have multiple versions of an image as
needed for your environment. Like a managed image, when
you use an image version to create a VM, the image version
is used to create new disks for the VM. Image versions can be
used multiple times.
NOTE
Before you begin
A Shared Image Gallery simplifies custom image sharing across your organization.
Custom images are like
marketplace images, but you create them yourself. Custom images can be used to
bootstrap deployment tasks like
preloading applications, application configurations, and other OS configurations.
The Shared Image Gallery lets you share your custom VM images with others in your
organization, within or
across regions, within an AAD tenant. Choose which images you want to share, which
regions you want to make
them available in, and who you want to share them with. You can create multiple
galleries so that you can logically
group shared images.
The gallery is a top-level resource that provides full role-based access control
(RBAC). Images can be versioned,
and you can choose to replicate each image version to a different set of Azure
regions. The gallery only works with
Managed Images.
The Shared Image Gallery feature has multiple resource types. We will be using or
building these in this article:
This article has been updated to use the new Azure PowerShell Az module. You can
still use the AzureRM module, which will
continue to receive bug fixes until at least December 2020. To learn more about the
new Az module and AzureRM
compatibility, see Introducing the new Azure PowerShell Az module. For Az module
installation instructions, see Install Azure
PowerShell.
To complete the example in this article, you must have an existing managed image.
You can follow Tutorial: Create
Launch Azure Cloud Shell
Get the managed image
$managedImage = Get-AzImage `
-ImageName myImage `
-ResourceGroupName myResourceGroup
Create an image gallery
$resourceGroup = New-AzResourceGroup `
-Name 'myGalleryRG' `
-Location 'West Central US'
$gallery = New-AzGallery `
-GalleryName 'myGallery' `
-ResourceGroupName $resourceGroup.ResourceGroupName `
-Location $resourceGroup.Location `
-Description 'Shared Image Gallery for my organization'
Create an image definition
a custom image of an Azure VM with Azure PowerShell to create one if needed. If the
managed image contains a
data disk, the data disk size cannot be more than 1 TB.
When working through this article, replace the resource group and VM names where
needed.
The Azure Cloud Shell is a free interactive shell that you can use to run the steps
in this article. It has common
Azure tools preinstalled and configured to use with your account.
To open the Cloud Shell, just select Try it from the upper right corner of a code
block. You can also launch Cloud
Shell in a separate browser tab by going to https://shell.azure.com/powershell.
Select Copy to copy the blocks of
code, paste it into the Cloud Shell, and press enter to run it.
You can see a list of images that are available in a resource group using Get-
AzImage. Once you know the image
name and what resource group it is in, you can use Get-AzImage again to get the
image object and store it in a
variable to use later. This example gets an image named myImage from the
"myResourceGroup" resource group
and assigns it to the variable $managedImage.
An image gallery is the primary resource used for enabling image sharing. Allowed
characters for Gallery name
are uppercase or lowercase letters, digits, dots, and periods. The gallery name
cannot contain dashes. Gallery
names must be unique within your subscription.
Create an image gallery using New-AzGallery. The following example creates a
gallery named myGallery in the
myGalleryRG resource group.
Image definitions create a logical grouping for images. They are used to manage
information about the image
versions that are created within them. Image definition names can be made up of
uppercase or lowercase letters,
digits, dots, dashes and periods. For more information about the values you can
specify for an image definition, see
Image definitions.
Create the image definition using New-AzGalleryImageDefinition. In this example,
the gallery image is named
myGalleryImage.
$galleryImage = New-AzGalleryImageDefinition `
-GalleryName $gallery.Name `
-ResourceGroupName $resourceGroup.ResourceGroupName `
-Location $gallery.Location `
-Name 'myImageDefinition' `
-OsState generalized `
-OsType Windows `
-Publisher 'myPublisher' `
-Offer 'myOffer' `
-Sku 'mySKU'
Create an image version
$region1 = @{Name='South Central US';ReplicaCount=1}
$region2 = @{Name='West Central US';ReplicaCount=2}
$targetRegions = @($region1,$region2)
$job = $imageVersion = New-AzGalleryImageVersion `
-GalleryImageDefinitionName $galleryImage.Name `
-GalleryImageVersionName '1.0.0' `
-GalleryName $gallery.Name `
-ResourceGroupName $resourceGroup.ResourceGroupName `
-Location $resourceGroup.Location `
-TargetRegion $targetRegions `
-Source $managedImage.Id.ToString() `
-PublishingProfileEndOfLifeDate '2020-01-01' `
-asJob
$job.State
NOTE
Share the gallery
Create an image version from a managed image using New-AzGalleryImageVersion.
Allowed characters for image version are numbers and periods. Numbers must be
within the range of a 32-bit
integer. Format: MajorVersion.MinorVersion.Patch.
In this example, the image version is 1.0.0 and it's replicated to both West
Central US and South Central US
datacenters. When choosing target regions for replication, remember that you also
have to include the source
region as a target for replication.
It can take a while to replicate the image to all of the target regions, so we have
created a job so we can track the
progress. To see the progress of the job, type $job.State .
You need to wait for the image version to completely finish being built and
replicated before you can use the same managed
image to create another image version.
You can also store your image version in Zone Redundant Storage by adding
-StorageAccountType Standard_ZRS when
you create the image version.
We recommend that you share access at the image gallery level. Use an email address
and the Get-AzADUser
cmdlet to get the object ID for the user, then use New-AzRoleAssignment to give
them access to the gallery.
Replace the example email, alinne_montes@contoso.com in this example, with your own
information.
# Get the object ID for the user
$user = Get-AzADUser -StartsWith alinne_montes@contoso.com
# Grant access to the user for our gallery
New-AzRoleAssignment `
-ObjectId $user.Id `
-RoleDefinitionName Reader `
-ResourceName $gallery.Name `
-ResourceType Microsoft.Compute/galleries `
-ResourceGroupName $resourceGroup.ResourceGroupName
Create VMs from an image
$resourceGroup = "myResourceGroup"
$location = "South Central US"
$vmName = "myVMfromImage"
# Create user object
$cred = Get-Credential -Message "Enter a username and password for the virtual
machine."
# Create a resource group
New-AzResourceGroup -Name $resourceGroup -Location $location
# Network pieces
$subnetConfig = New-AzVirtualNetworkSubnetConfig -Name mySubnet -AddressPrefix
192.168.1.0/24
$vnet = New-AzVirtualNetwork -ResourceGroupName $resourceGroup -Location $location
`
-Name MYvNET -AddressPrefix 192.168.0.0/16 -Subnet $subnetConfig
$pip = New-AzPublicIpAddress -ResourceGroupName $resourceGroup -Location $location
`
-Name "mypublicdns$(Get-Random)" -AllocationMethod Static -IdleTimeoutInMinutes 4
$nsgRuleRDP = New-AzNetworkSecurityRuleConfig -Name myNetworkSecurityGroupRuleRDP
-Protocol Tcp `
-Direction Inbound -Priority 1000 -SourceAddressPrefix * -SourcePortRange *
-DestinationAddressPrefix * `
-DestinationPortRange 3389 -Access Allow
$nsg = New-AzNetworkSecurityGroup -ResourceGroupName $resourceGroup -Location
$location `
-Name myNetworkSecurityGroup -SecurityRules $nsgRuleRDP
$nic = New-AzNetworkInterface -Name myNic -ResourceGroupName $resourceGroup
-Location $location `
-SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id -NetworkSecurityGroupId
$nsg.Id
# Create a virtual machine configuration using $imageVersion.Id to specify the
shared image
$vmConfig = New-AzVMConfig -VMName $vmName -VMSize Standard_D1_v2 | `
Set-AzVMOperatingSystem -Windows -ComputerName $vmName -Credential $cred | `
Set-AzVMSourceImage -Id $imageVersion.Id | `
Add-AzVMNetworkInterface -Id $nic.Id
# Create a virtual machine
New-AzVM -ResourceGroupName $resourceGroup -Location $location -VM $vmConfig
Shared image management
$galleries = Get-AzResource -ResourceType Microsoft.Compute/galleries
$galleries.Name
Once the image version is complete, you can create one or more new VMs. Using the
New-AzVM cmdlet.
This example creates a VM named myVMfromImage, in the myResourceGroup in the South
Central US datacenter.
Here are some examples of common management tasks and how to complete them using
PowerShell.
List all galleries by name.
List all image definitions by name.
$imageDefinitions = Get-AzResource -ResourceType Microsoft.Compute/galleries/images
$imageDefinitions.Name
$imageVersions = Get-AzResource -ResourceType
Microsoft.Compute/galleries/images/versions
$imageVersions.Name
Remove-AzGalleryImageVersion `
-GalleryImageDefinitionName myImageDefinition `
-GalleryName myGallery `
-Name 1.0.0 `
-ResourceGroupName myGalleryRG
Update resources
Update-AzGallery `
-Name $gallery.Name `
-ResourceGroupName $resourceGroup.Name
List all image versions by name.
Delete an image version. This example deletes the image version named 1.0.0.
There are some limitations on what can be updated. The following items can be
updated:
Shared image gallery:
Description
Image definition:
Recommended vCPUs
Recommended memory
Description
End of life date
Image version:
Regional replica count
Target regions
Exclusion from latest
End of life date
If you plan on adding replica regions, do not delete the source managed image. The
source managed image is
needed for replicating the image version to additional regions.
To update the description of a gallery, use Update-AzGallery.
This example shows how to use Update-AzGalleryImageDefinition to update the end-of-
life date for our image
definition.
Update-AzGalleryImageDefinition `
-GalleryName $gallery.Name `
-Name $galleryImage.Name `
-ResourceGroupName $resourceGroup.Name `
-EndOfLifeDate 01/01/2030
Update-AzGalleryImageVersion `
-GalleryImageDefinitionName $galleryImage.Name `
-GalleryName $gallery.Name `
-Name $galleryVersion.Name `
-ResourceGroupName $resourceGroup.Name `
-PublishingProfileExcludeFromLatest
Clean up resources
$resourceGroup = "myResourceGroup"
$gallery = "myGallery"
$imageDefinition = "myImageDefinition"
$imageVersion = "myImageVersion"
Remove-AzGalleryImageVersion `
-GalleryImageDefinitionName $imageDefinition `
-GalleryName $gallery `
-Name $imageVersion `
-ResourceGroupName $resourceGroup
Remove-AzGalleryImageDefinition `
-ResourceGroupName $resourceGroup `
-GalleryName $gallery `
-GalleryImageDefinitionName $imageDefinition
Remove-AzGallery `
-Name $gallery `
-ResourceGroupName $resourceGroup
Remove-AzResourceGroup -Name $resourceGroup
Next steps
This example shows how to use Update-AzGalleryImageVersion to exclude this image
version from being used as
the latest image.
When deleting resources, you need to start with last item in the nested resources -
the image version. Once
versions are deleted, you can delete the image definition. You can't delete the
gallery until all resources beneath it
have been deleted.
Azure Image Builder (preview) can help automate image version creation, you can
even use it to update and create
a new image version from an existing image version.
You can also create Shared Image Gallery resource using templates. There are
several Azure Quickstart Templates
available:
Create a Shared Image Gallery
Create an Image Definition in a Shared Image Gallery
Create an Image Version in a Shared Image Gallery
Create a VM from Image Version
For more information about Shared Image Galleries, see the Overview. If you run
into issues, see Troubleshooting
shared image galleries.
Create a shared image gallery using the Azure portal
5/23/2019 � 8 minutes to read � Edit Online
RESOURCE DESCRIPTION
Managed image This is a basic image that can be used alone or used to create
an image version in an image gallery. Managed images are
created from generalized VMs. A managed image is a special
type of VHD that can be used to make multiple VMs and can
now be used to create shared image versions.
Image gallery Like the Azure Marketplace, an image gallery is a repository
for managing and sharing images, but you control who has
access.
Image definition Images are defined within a gallery and carry information
about the image and requirements for using it internally. This
includes whether the image is Windows or Linux, release notes,
and minimum and maximum memory requirements. It is a
definition of a type of image.
Image version An image version is what you use to create a VM when using
a gallery. You can have multiple versions of an image as
needed for your environment. Like a managed image, when
you use an image version to create a VM, the image version
is used to create new disks for the VM. Image versions can be
used multiple times.
Before you begin
Sign in to Azure
A Shared Image Gallery simplifies custom image sharing across your organization.
Custom images are like
marketplace images, but you create them yourself. Custom images can be used to
bootstrap deployment tasks like
preloading applications, application configurations, and other OS configurations.
The Shared Image Gallery lets you share your custom VM images with others in your
organization, within or
across regions, within an AAD tenant. Choose which images you want to share, which
regions you want to make
them available in, and who you want to share them with. You can create multiple
galleries so that you can logically
group shared images.
The gallery is a top-level resource that provides full role-based access control
(RBAC). Images can be versioned,
and you can choose to replicate each image version to a different set of Azure
regions. The gallery only works with
Managed Images.
The Shared Image Gallery feature has multiple resource types. We will be using or
building these in this article:
To complete the example in this article, you must have an existing managed image.
You can follow Tutorial: Create a
custom image of an Azure VM with Azure PowerShell to create one if needed. If the
managed image contains a
data disk, the data disk size cannot be more than 1 TB.
When working through this article, replace the resource group and VM names where
needed.
NOTE
Create an image gallery
Create an image definition
Create an image version
Sign in to the Azure portal at https://portal.azure.com.
If you registered to use Shared Image Galleries during the preview, you might need
to re-register the Microsoft.Compute
provider. Open Cloud Shell and type: az provider register -n Microsoft.Compute
An image gallery is the primary resource used for enabling image sharing. Allowed
characters for Gallery name are
uppercase or lowercase letters, digits, dots, and periods. The gallery name cannot
contain dashes. Gallery names
must be unique within your subscription.
The following example creates a gallery named myGallery in the myGalleryRG resource
group.
1. Select Create a resource in the upper left-hand corner of the Azure portal.
2. Use the type Shared image gallery in the search box and select Shared image
gallery in the results.
3. In the Shared image gallery page, click Create.
4. Select the correct subscription.
5. In Resource group, select Create new and type myGalleryRG for the name.
6. In Name, type myGallery for the name of the gallery.
7. Leave the default for Region.
8. You can type a short description of the gallery, like My image gallery for
testing. and then click Review +
create.
9. After validation passes, select Create.
10. When the deployment is finished, select Go to resource.
Image definitions create a logical grouping for images. They are used to manage
information about the image
versions that are created within them. Image definition names can be made up of
uppercase or lowercase letters,
digits, dots, dashes and periods. For more information about the values you can
specify for an image definition, see
Image definitions.
Create the gallery image definition inside of your gallery. In this example, the
gallery image is named
myImageDefinition.
1. On the page for your new image gallery, select Add a new image definition from
the top of the page.
2. For Image definition name, type myImageDefinition.
3. For Operating system, select the correct option based on your source image.
4. For Publisher, type myPublisher.
5. For Offer, type myOffer.
6. For SKU, type mySKU.
7. When finished, select Review + create.
8. After the image definition passes validation, select Create.
9. When the deployment is finished, select Go to resource.
Create an image version from a managed image. In this example, the image version is
1.0.0 and it's replicated to
both West Central US and South Central US datacenters. When choosing target regions
for replication, remember
that you also have to include the source region as a target for replication.
Share the gallery
Create VMs from an image
Allowed characters for image version are numbers and periods. Numbers must be
within the range of a 32-bit
integer. Format: MajorVersion.MinorVersion.Patch.
1. In the page for your image definition, select Add version from the top of the
page.
2. In Region, select the region where your managed image is stored. Image versions
need to be created in the
same region as the managed image they are created from.
3. For Name, type 1.0.0. The image version name should follow major.minor.patch
format using integers.
4. In Source image, select your source managed image from the drop-down.
5. In Exclude from latest, leave the default value of No.
6. For End of life date, select a date from the calendar that is a couple of months
in the future.
7. In Replication, leave the Default replica count as 1. You need to replicate to
the source region, so leave the
first replica as the default and then pick a second replica region to be East US.
8. When you are done, select Review + create. Azure will validate the
configuration.
9. When image version passes validation, select Create.
10. When the deployment is finished, select Go to resource.
It can take a while to replicate the image to all of the target regions.
We recommend that you share access at the image gallery level. The following walks
you through sharing the
gallery that you just created.
1. Open the Azure portal.
2. In the menu at the left, select Resource groups.
3. In the list of resource groups, select myGalleryRG. The blade for your resource
group will open.
4. In the menu on the left of the myGalleryRG page, select Access control (IAM).
5. Under Add a role assignment, select Add. The Add a role assignment pane will
open.
6. Under Role, select Reader.
7. Under assign access to, leave the default of Azure AD user, group, or service
principal.
8. Under Select, type in the email address of the person that you would like to
invite.
9. If the user is outside of your organization, you will see the message This user
will be sent an email that
enables them to collaborate with Microsoft. Select the user with the email address
and then click Save.
If the user is outside of your organization, they will get an email invitation to
join the organization. The user needs
to accept the invitation, then they will be able to see the gallery and all of the
image definitions and versions in their
list of resources.
Once the image version is complete, you can create one or more new VMs.
This example creates a VM named myVMfromImage, in the myResourceGroup in the East
US datacenter.
1. On the page for your image version, select Create VM from the menu at the top of
the page.
2. For Resource group, select Create new and type myResourceGroup for the name.
3. In Virtual machine name, type myVM.
4. For Region, select East US.
5. For Availability options, leave the default of No infrastructure redundancy
required.
6. The value for Image should be automatically filled in if you started from the
page for the image version.
7. For Size, choose a VM size from the list of available sizes and then click
"Select".
8. Under Administrator account, provide a username, such as azureuser and a
password. The password must be
Clean up resources
Next steps
at least 12 characters long and meet the defined complexity requirements.
9. If you want to allow remote access to the VM, under Public inbound ports, choose
Allow selected ports and
then select RDP (3389) from the drop-down. If you don't want to allow remote access
to the VM, leave None
selected for Public inbound ports.
10. When you are finished, select the Review + create button at the bottom of the
page.
11. After the VM passes validation, select Create at the bottom of the page to
start the deployment.
When no longer needed, you can delete the resource group, virtual machine, and all
related resources. To do so,
select the resource group for the virtual machine, select Delete, then confirm the
name of the resource group to
delete.
If you want to delete individual resources, you need to delete them in reverse
order. For example, to delete an
image definition, you need to delete all of the image versions created from that
image.
You can also create Shared Image Gallery resource using templates. There are
several Azure Quickstart Templates
available:
Create a Shared Image Gallery
Create an Image Definition in a Shared Image Gallery
Create an Image Version in a Shared Image Gallery
Create a VM from Image Version
For more information about Shared Image Galleries, see the Overview. If you run
into issues, see Troubleshooting
shared image galleries.
Create a shared image gallery with the Azure CLI
5/23/2019 � 7 minutes to read � Edit Online
RESOURCE DESCRIPTION
Managed image This is a basic image that can be used alone or used to create an
image version in an image gallery. Managed images are
created from generalized VMs. A managed image is a special
type of VHD that can be used to make multiple VMs and can
now be used to create shared image versions.
Image gallery Like the Azure Marketplace, an image gallery is a repository
for managing and sharing images, but you control who has
access.
Image definition Images are defined within a gallery and carry information about
the image and requirements for using it internally. This includes
whether the image is Windows or Linux, release notes, and
minimum and maximum memory requirements. It is a definition
of a type of image.
Image version An image version is what you use to create a VM when using
a gallery. You can have multiple versions of an image as needed
for your environment. Like a managed image, when you use an
image version to create a VM, the image version is used to
create new disks for the VM. Image versions can be used
multiple times.
Before you begin
Launch Azure Cloud Shell
A Shared Image Gallery simplifies custom image sharing across your organization.
Custom images are like
marketplace images, but you create them yourself. Custom images can be used to
bootstrap configurations such as
preloading applications, application configurations, and other OS configurations.
The Shared Image Gallery lets you share your custom VM images with others in your
organization, within or across
regions, within an AAD tenant. Choose which images you want to share, which regions
you want to make them
available in, and who you want to share them with. You can create multiple
galleries so that you can logically group
shared images.
The gallery is a top-level resource that provides full role-based access control
(RBAC). Images can be versioned, and
you can choose to replicate each image version to a different set of Azure regions.
The gallery only works with
Managed Images.
The Shared Image Gallery feature has multiple resource types. We will be using or
building these in this article:
To complete the example in this article, you must have an existing managed image of
a generalized VM. For more
information, see Tutorial: Create a custom image of an Azure VM with the Azure CLI
2.0. If the managed image
contains a data disk, the data disk size cannot be more than 1 TB.
The Azure Cloud Shell is a free interactive shell that you can use to run the steps
in this article. It has common Azure
tools preinstalled and configured to use with your account.
To open the Cloud Shell, just select Try it from the upper right corner of a code
block. You can also launch Cloud Shell
Create an image gallery
az group create --name myGalleryRG --location WestCentralUS
az sig create --resource-group myGalleryRG --gallery-name myGallery
Create an image definition
az sig image-definition create \
--resource-group myGalleryRG \
--gallery-name myGallery \
--gallery-image-definition myImageDefinition \
--publisher myPublisher \
--offer myOffer \
--sku 16.04-LTS \
--os-type Linux
Create an image version
az sig image-version create \
--resource-group myGalleryRG \
--gallery-name myGallery \
--gallery-image-definition myImageDefinition \
--gallery-image-version 1.0.0 \
--target-regions "WestCentralUS" "SouthCentralUS=1" "EastUS2=1=Standard_ZRS" \
--replica-count 2 \
--managed-image "/subscriptions/<subscription
ID>/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/myImage"
in a separate browser tab by going to https://shell.azure.com/bash. Select Copy to
copy the blocks of code, paste it
into the Cloud Shell, and press enter to run it.
If you prefer to install and use the CLI locally, see Install Azure CLI.
An image gallery is the primary resource used for enabling image sharing. Allowed
characters for Gallery name are
uppercase or lowercase letters, digits, dots, and periods. The gallery name cannot
contain dashes. Gallery names must
be unique within your subscription.
Create an image gallery using az sig create. The following example creates a
gallery named myGallery in
myGalleryRG.
Image definitions create a logical grouping for images. They are used to manage
information about the image
versions that are created within them. Image definition names can be made up of
uppercase or lowercase letters,
digits, dots, dashes, and periods. For more information about the values you can
specify for an image definition, see
Image definitions.
Create an initial image definition in the gallery using az sig image-definition
create.
Create versions of the image as needed using az image gallery create-image-version.
You will need to pass in the ID
of the managed image to use as a baseline for creating the image version. You can
use az image list to get information
about images that are in a resource group.
Allowed characters for image version are numbers and periods. Numbers must be
within the range of a 32-bit integer.
Format: MajorVersion.MinorVersion.Patch.
In this example, the version of our image is 1.0.0 and we are going to create 2
replicas in the West Central US region,
1 replica in the South Central US region and 1 replica in the East US 2 region
using zone-redundant storage.
NOTE
Share the gallery
az sig show \
--resource-group myGalleryRG \
--gallery-name myGallery \
--query id
az role assignment create --role "Reader" --assignee <email address> --scope
<gallery ID>
Create a VM
az vm create\
--resource-group myGalleryRG \
--name myVM \
--image "/subscriptions/subscription ID where the gallery is
located>/resourceGroups/myGalleryRG/providers/Microsoft.Compute/galleries/myGallery
/images/myImageDefinition" \
--generate-ssh-keys
Using RBAC to share images
List information
az sig list -o table
You need to wait for the image version to completely finish being built and
replicated before you can use the same managed
image to create another image version.
You can also store all of your image version replicas in Zone Redundant Storage by
adding
--storage-account-type standard_zrs when you create the image version.
We recommend that you share with other users at the gallery level. To get the
object ID of your gallery, use az sig
show.
Use the object ID as a scope, along with an email address and az role assignment
create to give a user access to the
shared image gallery.
Create a VM from the latest image version using az vm create.
You can also use a specific version by using the image version ID for the --image
parameter. For example, to use
image version 1.0.0 type:
--image "/subscriptions/<subscription ID where the gallery is
located>/resourceGroups/myGalleryRG/providers/Microsoft.Compute/galleries/myGallery
/images/myImageDefinition/versions/1.0.0"
.
You can share images across subscriptions using Role-Based Access Control (RBAC).
Any user that has read
permissions to an image version, even across subscriptions, will be able to deploy
a Virtual Machine using the image
version.
For more information about how to share resources using RBAC, see Manage access
using RBAC and Azure CLI.
Get the location, status and other information about the available image galleries
using az sig list.
az sig image-definition list --resource-group myGalleryRG --gallery-name myGallery
-o table
az sig image-version list --resource-group myGalleryRG --gallery-name myGallery
--gallery-image-definition
myImageDefinition -o table
az sig image-version show \
--resource-group myGalleryRG \
--gallery-name myGallery \
--gallery-image-definition myImageDefinition \
--gallery-image-version 1.0.0 \
--query "id"
Update resources
az sig update \
--gallery-name myGallery \
--resource-group myGalleryRG \
--set description="My updated description."
List the image definitions in a gallery, including information about OS type and
status, using az sig image-definition
list.
List the shared image versions in a gallery, using az sig image-version list.
Get the ID of an image version using az sig image-version show.
There are some limitations on what can be updated. The following items can be
updated:
Shared image gallery:
Description
Image definition:
Recommended vCPUs
Recommended memory
Description
End of life date
Image version:
Regional replica count
Target regions
Exclusion from latest
End of life date
If you plan on adding replica regions, do not delete the source managed image. The
source managed image is needed
for replicating the image version to additional regions.
Update the description of a gallery using (az sig update.
Update the description of an image definition using az sig image-definition update.
az sig image-definition update \
--gallery-name myGallery\
--resource-group myGalleryRG \
--gallery-image-definition myImageDefinition \
--set description="My updated description."
az sig image-version update \
--resource-group myGalleryRG \
--gallery-name myGallery \
--gallery-image-definition myImageDefinition \
--gallery-image-version 1.0.0 \
--add publishingProfile.targetRegions name=eastus
Delete resources
az sig image-version delete \
--resource-group myGalleryRG \
--gallery-name myGallery \
--gallery-image-definition myImageDefinition \
--gallery-image-version 1.0.0
az sig image-definition delete \
--resource-group myGalleryRG \
--gallery-name myGallery \
--gallery-image-definition myImageDefinition
az sig delete \
--resource-group myGalleryRG \
--gallery-name myGallery
Next steps
Update an image version to add a region to replicate to using az sig image-version
update. This change will take a
while as the image gets replicated to the new region.
You have to delete resources in reverse order, by deleting the image version first.
After you delete all of the image
versions, you can delete the image definition. After you delete all image
definitions, you can delete the gallery.
Delete an image version using az sig image-version delete.
Delete an image definition using az sig image-definition delete.
Delete an image gallery using az sig delete.
Azure Image Builder (preview) can help automate image version creation, you can
even use it to update and create a
new image version from an existing image version.
You can also create Shared Image Gallery resources using templates. There are
several Azure Quickstart Templates
available:
Create a Shared Image Gallery
Create an Image Definition in a Shared Image Gallery
Create an Image Version in a Shared Image Gallery
Create a VM from Image Version
For more information about Shared Image Galleries, see the Overview. If you run
into issues, see Troubleshooting
shared image galleries.
Create a shared image gallery using the Azure portal
5/23/2019 � 8 minutes to read � Edit Online
RESOURCE DESCRIPTION
Managed image This is a basic image that can be used alone or used to create
an image version in an image gallery. Managed images are
created from generalized VMs. A managed image is a special
type of VHD that can be used to make multiple VMs and can
now be used to create shared image versions.
Image gallery Like the Azure Marketplace, an image gallery is a repository
for managing and sharing images, but you control who has
access.
Image definition Images are defined within a gallery and carry information
about the image and requirements for using it internally. This
includes whether the image is Windows or Linux, release
notes, and minimum and maximum memory requirements. It
is a definition of a type of image.
Image version An image version is what you use to create a VM when
using a gallery. You can have multiple versions of an image as
needed for your environment. Like a managed image, when
you use an image version to create a VM, the image version
is used to create new disks for the VM. Image versions can be
used multiple times.
Before you begin
Sign in to Azure
A Shared Image Gallery simplifies custom image sharing across your organization.
Custom images are like
marketplace images, but you create them yourself. Custom images can be used to
bootstrap deployment tasks like
preloading applications, application configurations, and other OS configurations.
The Shared Image Gallery lets you share your custom VM images with others in your
organization, within or
across regions, within an AAD tenant. Choose which images you want to share, which
regions you want to make
them available in, and who you want to share them with. You can create multiple
galleries so that you can logically
group shared images.
The gallery is a top-level resource that provides full role-based access control
(RBAC). Images can be versioned,
and you can choose to replicate each image version to a different set of Azure
regions. The gallery only works with
Managed Images.
The Shared Image Gallery feature has multiple resource types. We will be using or
building these in this article:
To complete the example in this article, you must have an existing managed image.
You can follow Tutorial: Create
a custom image of an Azure VM with Azure PowerShell to create one if needed. If the
managed image contains a
data disk, the data disk size cannot be more than 1 TB.
When working through this article, replace the resource group and VM names where
needed.
NOTE
Create an image gallery
Create an image definition
Create an image version
Sign in to the Azure portal at https://portal.azure.com.
If you registered to use Shared Image Galleries during the preview, you might need
to re-register the Microsoft.Compute
provider. Open Cloud Shell and type: az provider register -n Microsoft.Compute
An image gallery is the primary resource used for enabling image sharing. Allowed
characters for Gallery name
are uppercase or lowercase letters, digits, dots, and periods. The gallery name
cannot contain dashes. Gallery
names must be unique within your subscription.
The following example creates a gallery named myGallery in the myGalleryRG resource
group.
1. Select Create a resource in the upper left-hand corner of the Azure portal.
2. Use the type Shared image gallery in the search box and select Shared image
gallery in the results.
3. In the Shared image gallery page, click Create.
4. Select the correct subscription.
5. In Resource group, select Create new and type myGalleryRG for the name.
6. In Name, type myGallery for the name of the gallery.
7. Leave the default for Region.
8. You can type a short description of the gallery, like My image gallery for
testing. and then click Review +
create.
9. After validation passes, select Create.
10. When the deployment is finished, select Go to resource.
Image definitions create a logical grouping for images. They are used to manage
information about the image
versions that are created within them. Image definition names can be made up of
uppercase or lowercase letters,
digits, dots, dashes and periods. For more information about the values you can
specify for an image definition, see
Image definitions.
Create the gallery image definition inside of your gallery. In this example, the
gallery image is named
myImageDefinition.
1. On the page for your new image gallery, select Add a new image definition from
the top of the page.
2. For Image definition name, type myImageDefinition.
3. For Operating system, select the correct option based on your source image.
4. For Publisher, type myPublisher.
5. For Offer, type myOffer.
6. For SKU, type mySKU.
7. When finished, select Review + create.
8. After the image definition passes validation, select Create.
9. When the deployment is finished, select Go to resource.
Create an image version from a managed image. In this example, the image version is
1.0.0 and it's replicated to
both West Central US and South Central US datacenters. When choosing target regions
for replication, remember
that you also have to include the source region as a target for replication.
Share the gallery
Create VMs from an image
Allowed characters for image version are numbers and periods. Numbers must be
within the range of a 32-bit
integer. Format: MajorVersion.MinorVersion.Patch.
1. In the page for your image definition, select Add version from the top of the
page.
2. In Region, select the region where your managed image is stored. Image versions
need to be created in the
same region as the managed image they are created from.
3. For Name, type 1.0.0. The image version name should follow major.minor.patch
format using integers.
4. In Source image, select your source managed image from the drop-down.
5. In Exclude from latest, leave the default value of No.
6. For End of life date, select a date from the calendar that is a couple of months
in the future.
7. In Replication, leave the Default replica count as 1. You need to replicate to
the source region, so leave the
first replica as the default and then pick a second replica region to be East US.
8. When you are done, select Review + create. Azure will validate the
configuration.
9. When image version passes validation, select Create.
10. When the deployment is finished, select Go to resource.
It can take a while to replicate the image to all of the target regions.
We recommend that you share access at the image gallery level. The following walks
you through sharing the
gallery that you just created.
1. Open the Azure portal.
2. In the menu at the left, select Resource groups.
3. In the list of resource groups, select myGalleryRG. The blade for your resource
group will open.
4. In the menu on the left of the myGalleryRG page, select Access control (IAM).
5. Under Add a role assignment, select Add. The Add a role assignment pane will
open.
6. Under Role, select Reader.
7. Under assign access to, leave the default of Azure AD user, group, or service
principal.
8. Under Select, type in the email address of the person that you would like to
invite.
9. If the user is outside of your organization, you will see the message This user
will be sent an email that
enables them to collaborate with Microsoft. Select the user with the email address
and then click Save.
If the user is outside of your organization, they will get an email invitation to
join the organization. The user needs
to accept the invitation, then they will be able to see the gallery and all of the
image definitions and versions in
their list of resources.
Once the image version is complete, you can create one or more new VMs.
This example creates a VM named myVMfromImage, in the myResourceGroup in the East
US datacenter.
1. On the page for your image version, select Create VM from the menu at the top of
the page.
2. For Resource group, select Create new and type myResourceGroup for the name.
3. In Virtual machine name, type myVM.
4. For Region, select East US.
5. For Availability options, leave the default of No infrastructure redundancy
required.
6. The value for Image should be automatically filled in if you started from the
page for the image version.
7. For Size, choose a VM size from the list of available sizes and then click
"Select".
8. Under Administrator account, provide a username, such as azureuser and a
password. The password must be
Clean up resources
Next steps
at least 12 characters long and meet the defined complexity requirements.
9. If you want to allow remote access to the VM, under Public inbound ports, choose
Allow selected ports and
then select RDP (3389) from the drop-down. If you don't want to allow remote access
to the VM, leave None
selected for Public inbound ports.
10. When you are finished, select the Review + create button at the bottom of the
page.
11. After the VM passes validation, select Create at the bottom of the page to
start the deployment.
When no longer needed, you can delete the resource group, virtual machine, and all
related resources. To do so,
select the resource group for the virtual machine, select Delete, then confirm the
name of the resource group to
delete.
If you want to delete individual resources, you need to delete them in reverse
order. For example, to delete an
image definition, you need to delete all of the image versions created from that
image.
You can also create Shared Image Gallery resource using templates. There are
several Azure Quickstart Templates
available:
Create a Shared Image Gallery
Create an Image Definition in a Shared Image Gallery
Create an Image Version in a Shared Image Gallery
Create a VM from Image Version
For more information about Shared Image Galleries, see the Overview. If you run
into issues, see Troubleshooting
shared image galleries.
Share gallery VM images across Azure tenants
5/6/2019 � 3 minutes to read � Edit Online
Create the app registration
Give Tenant 2 access
https://login.microsoftonline.com/<Tenant 2 ID>/oauth2/authorize?
client_id=<Application (client)
ID>&response_type=code&redirect_uri=https%3A%2F%2Fwww.microsoft.com%2F
Shared Image Galleries let you share images using RBAC. You can use RBAC to share
images within your tenant,
and even to individuals outside of your tenant. But, if you want to share images
outside of your Azure tenant, at
scale, you should create an app registration to facilitate sharing. Using an app
registration can enable more
complex sharing scenarios, like:
Managing shared images when one company acquires another, and the Azure
infrastructure is spread across
separate tenants.
Azure Partners manage Azure infrastructure on behalf of their customers.
Customization of images is done
within the partners tenant, but the infrastructure deployments will happen in the
customer's tenant.
Create an application registration that will be used by both tenants to share the
image gallery resources.
1. Open the App registrations (preview) in the Azure portal.
2. Select New registration from the menu at the top of the page.
3. In Name, type myGalleryApp.
4. In Supported account types, select Accounts in any organizational directory and
personal Microsoft
accounts.
5. In Redirect URI, type https://www.microsoft.com and then select Register. After
the app registration has been
created, the overview page will open.
6. On the overview page, copy the Application (client) ID and save for use later.
7. Select Certificates & secrets, and then select New client secret.
8. In Description, type Shared image gallery cross-tenant app secret.
9. In Expires, leave the default of In 1 year and then select Add.
10. Copy the value of the secret and save it to a safe place. You cannot retrieve
it after you leave the page.
Give the app registration permission to use the shared image gallery.
1. In the Azure portal, select the Shared Image Gallery that you want to share with
another tenant.
2. Select select Access control (IAM), and under Add role assignment select Add.
3. Under Role, select Reader.
4. Under Assign access to:, leave this as Azure AD user, group, or service
principal.
5. Under Select, type myGalleryApp and select it when it shows up in the list. When
you are done, select Save.
Give Tenant 2 access to the application by requesting a sign-in using a browser.
Replace with the tenant ID for the
tenant that you would like to share your image gallery with. Replace <Application
(client) ID> with the application
ID of the app registration you created. When done making the replacements, paste
the URL into a browser and
follow the sign-in prompts to sign into Tenant 2.
In the Azure portal sign in as Tenant 2 and give the app registration access to the
resource group where you want
NOTE
Create a VM using PowerShell
$applicationId = '<App ID>'
$secret = <Secret> | ConvertTo-SecureString -AsPlainText -Force
$tenant1 = "<Tenant 1 ID>"
$tenant2 = "<Tenant 2 ID>"
$cred = New-Object -TypeName PSCredential -ArgumentList $applicationId, $secret
Clear-AzContext
Connect-AzAccount -ServicePrincipal -Credential $cred -Tenant "<Tenant 1 ID>"
Connect-AzAccount -ServicePrincipal -Credential $cred -Tenant "<Tenant 2 ID>"
$resourceGroup = "myResourceGroup"
$image = "/subscriptions/<Tenant 1 subscription>/resourceGroups/<Resource
group>/providers/Microsoft.Compute/galleries/<Gallery>/images/<Image
definition>/versions/<version>"
New-AzVm `
-ResourceGroupName "myResourceGroup" `
-Name "myVMfromImage" `
-Image $image `
-Location "South Central US" `
-VirtualNetworkName "myImageVnet" `
-SubnetName "myImageSubnet" `
-SecurityGroupName "myImageNSG" `
-PublicIpAddressName "myImagePIP" `
-OpenPorts 3389
Next steps
to create the VM.
1. Select the resource group and then select Access control (IAM). Under Add role
assignment select Add.
2. Under Role, type Contributor.
3. Under Assign access to:, leave this as Azure AD user, group, or service
principal.
4. Under Select type myGalleryApp then select it when it shows up in the list. When
you are done, select Save.
You need to wait for the image version to completely finish being built and
replicated before you can use the same managed
image to create another image version.
Log into both tenants using the application ID, secret and tenant ID.
Create the VM in the resource group that has permission on the app registration.
Replace the information in this
example with your own.
You can also create shared image gallery resources using the Azure portal.
Troubleshooting shared image galleries
5/6/2019 � 3 minutes to read � Edit Online
Unable to create a shared image gallery
Unable to create an image definition
Unable to create an image version
If you run into issues while performing any operations on shared image galleries,
image definitions, and image
versions, run the failing command again in debug mode. Debug mode is activated by
passing the -debug switch
with CLI and the -Debug switch with PowerShell. Once you�ve located the error,
follow this document to
troubleshoot the errors.
Possible causes:
The gallery name is invalid.
Allowed characters for Gallery name are uppercase or lowercase letters, digits,
dots, and periods. The gallery
name cannot contain dashes. Change the gallery name and try again.
The gallery name is not unique within your subscription.
Pick another gallery name and try again.
Possible causes:
image definition name is invalid.
Allowed characters for image definition are uppercase or lowercase letters, digits,
dots, dashes, and periods.
Change the image definition name and try again.
The mandatory properties for creating an image definition are not populated.
The properties such as name, publisher, offer, sku, and OS type are mandatory.
Verify if all the properties are being
passed.
Make sure that the OSType, either Linux or Windows, of the image definition is the
same as the source managed
image that you are using to create the image version.
Possible causes:
Image version name is invalid.
Allowed characters for image version are numbers and periods. Numbers must be
within the range of a 32-bit
integer. Format: MajorVersion.MinorVersion.Patch. Change the image version name and
try again.
Source managed image from which the image version is being created is not found.
Check if the source image exists and is in the same region as the image version.
The managed image isn't done being provisioned.
Make sure the provisioning state of the source managed image is Succeeded.
The target region list does not include the source region.
Unable to create a VM or a scale set
Unable to share resources
Replication is slow
Azure limits and quotas
Next steps
The target region list must include the source region of the image version. Make
sure you have included the
source region in the list of target regions where you want Azure to replicate your
image version to.
Replication to all the target regions not completed.
Use the --expand ReplicationStatus flag to check if the replication to all the
specified target regions has been
completed. If not, wait up to 6 hours for the job to complete. If it fails, run the
command again to create and
replicate the image version. If there are a lot of target regions the image version
is being replicated to, consider
doing the replication in phases.
Possible causes:
The user trying to create a VM or virtual machine scale set doesn�t have the read
access to the image version.
Contact the subscription owner and ask them to give read access to the image
version or the parent resources
(like the shared image gallery or image definition) through Role Based Access
Control (RBAC).
The image version is not found.
Verify that the region you are trying to create a VM or virtual machine scale in is
included in the list of target
regions of the image version. If the region is already in the list of target
regions, then verify if the replication job
has been completed. You can use the -ReplicationStatus flag to check if the
replication to all the specified target
regions has been completed.
The VM or virtual machine scale set creation takes a long time.
Verify that the OSType of the image version that you are trying to create the VM or
virtual machine scale set
from has the same OSType of the source managed image that you used to create the
image version.
The sharing of shared image gallery, image definition, and image version resources
across subscriptions is
enabled using Role-Based Access Control (RBAC).
Use the --expand ReplicationStatus flag to check if the replication to all the
specified target regions has been
completed. If not, wait for up to 6 hours for the job to complete. If it fails,
trigger the command again to create and
replicate the image version. If there are a lot of target regions the image version
is being replicated to, consider
doing the replication in phases.
Azure limits and quotas apply to all shared image gallery, image definition, and
image version resources. Make
sure you are within the limits for your subscriptions.
Learn more about shared image galleries.
Preview: Azure Image Builder overview
5/6/2019 � 4 minutes to read � Edit Online
IMPORTANT
Preview features
Regions
Standardized virtual machine (VM) images allow organizations to migrate to the
cloud and ensure consistency in
the deployments. Images typically include predefined security and configuration
settings and necessary software.
Setting up your own imaging pipeline requires time, infrastructure and setup, but
with Azure VM Image Builder,
just provide a simple configuration describing your image, submit it to the
service, and the image is built, and
distributed.
The Azure VM Image Builder (Azure Image Builder) lets you start with a Windows or
Linux-based Azure
Marketplace image, existing custom images or Red Hat Enterprise Linux (RHEL) ISO
and begin to add your own
customizations. Because the Image Builder is built on HashiCorp Packer, you can
also import your existing Packer
shell provisioner scripts. You can also specify where you would like your images
hosted, in the Azure Shared Image
Gallery (virtual-machines-common-shared-image-galleries.md), as a managed image or
a VHD.
Azure Image Builder is currently in public preview. This preview version is
provided without a service level agreement, and it's
not recommended for production workloads. Certain features might not be supported
or might have constrained capabilities.
For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
For the preview, these features are supported:
Creation of golden baseline images, that includes your minimum security and
corporate configurations, and
allow departments to customize it further for their needs.
Patching of existing images, Image Builder will allow you to continually patch
existing custom images.
Integration with the Azure Shared Image Gallery, allows you to distribute, version,
and scale images globally,
and gives you an image management system.
Integration with existing image build pipelines, just call Image Builder from your
pipeline, or use the simple
Preview Image Builder Azure DevOps Task.
Migrate an existing image customization pipeline to Azure. Use your existing
scripts, commands, and processes
to customize images.
Use Red Hat Bring Your Own Subscription support. Create Red Hat Enterprise images
for use with your
eligible, unused Red Hat subscriptions.
Creation of images in VHD format.
The Azure Image Builder Service will be available for preview in these regions.
Images can be distributed outside
of these regions.
East US
East US 2
West Central US
West US
West US 2
OS support
How it works
AIB will support Azure Marketplace base OS images:
Ubuntu 18.04
Ubuntu 16.04
RHEL 7.6
CentOS 7.6
Windows 2016
Windows 2019
The Azure Image Builder is a fully managed Azure service that is accessible by an
Azure resource provider. The
Azure Image Builder process has three main parts: source, customize and distribute,
these are represented in a
template. The diagram below shows the components, with some of their properties.
Image Builder process
1. Create the Image Template as a .json file. This .json file contains information
about the image source,
customizations, and distribution. There are multiple examples in the Azure Image
Builder GitHub repository.
2. Submit it to the service, this will create an Image Template artifact in the
resource group you specify. In the
background, Image Builder will download the source image or ISO, and scripts as
needed. These are stored in a
separate resource group that is automatically created in your subscription, in the
format: IT__.
3. Once the Image Template is created, you can then build the image. In the
background Image Builder uses the
template and source files to create a VM, network, and storage in the IT__ resource
group.
4. As part of the image creation, Image builder distributes the image it according
to the template, then deletes the
additional resources in the IT__ resource group that was created for the process.
Permissions
az role assignment create \
--assignee cf32a0cc-373c-47c9-9156-0db11f6a6dfc \
--role Contributor \
--scope /subscriptions/$subscriptionID/resourceGroups/<distributeResoureGroupName>
Costs
Next steps
To allow Azure VM Image Builder to distribute images to either the managed images
or to a Shared Image Gallery,
you will need to provide 'Contributor' permissions for the service "Azure Virtual
Machine Image Builder" (app ID:
cf32a0cc-373c-47c9-9156-0db11f6a6dfc) on the resource groups.
If you are using an existing custom managed image or image version, then the Azure
Image Builder will need a
minimum of �Reader� access to those resource groups.
You can assign access using the Azure CLI:
If the service account is not found, that may mean that the subscription where you
are adding the role assignment
has not yet registered for the resource provider.
You will incur some compute, networking and storage costs when creating, building
and storing images with Azure
Image Builder. These costs are similar to the costs incurred in manually creating
custom images. For the resources,
you will be charged at your Azure rates.
During the image creation process, files are downloaded and stored in the
IT_<DestinationResourceGroup>_<TemplateName> resource group, which will incur a
small storage costs. f you do not
want to keep these, delete the Image Template after the image build.
Image Builder creates a VM using a D1v2 VM size, and the storage, and networking
needed for the VM. These
resources will last for the duration of the build process, and will be deleted once
Image Builder has finished
creating the image.
Azure Image Builder will distribute the image to your chosen regions, which might
incur network egress charges.
To try out the Azure Image Builder, see the articles for building Linux or Windows
images.
Preview: Create a Windows VM with Azure Image
Builder
5/6/2019 � 3 minutes to read � Edit Online
IMPORTANT
Register the features
az feature register --namespace Microsoft.VirtualMachineImages --name
VirtualMachineTemplatePreview
az feature show --namespace Microsoft.VirtualMachineImages --name
VirtualMachineTemplatePreview | grep state
az provider show -n Microsoft.VirtualMachineImages | grep registrationState
az provider show -n Microsoft.Storage | grep registrationState
az provider register -n Microsoft.VirtualMachineImages
az provider register -n Microsoft.Storage
Create a resource group
This article is to show you how you can create a customized Windows image using the
Azure VM Image Builder.
The example in this article uses three different customizers for customizing the
image:
PowerShell (ScriptUri) - download and run a PowerShell script.
Windows Restart - restarts the VM.
PowerShell (inline) - run a specific command. In this example, it creates a
directory on the VM using
mkdir c:\\buildActions .
File - copy a file from GitHub onto the VM. This example copies index.md to
c:\buildArtifacts\index.html on
the VM.
We will be using a sample .json template to configure the image. The .json file we
are using is here:
helloImageTemplateWin.json.
Azure Image Builder is currently in public preview. This preview version is
provided without a service level agreement, and it's
not recommended for production workloads. Certain features might not be supported
or might have constrained capabilities.
For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
To use Azure Image Builder during the preview, you need to register the new
feature.
Check the status of the feature registration.
Check your registration.
If they do not say registered, run the following:
# Resource group name - we are using myImageBuilderRG in this example
imageResourceGroup=myWinImgBuilderRG
# Region location
location=WestUS2
# Name for the image
imageName=myWinBuilderImage
# Run output name
runOutputName=aibWindows
# name of the image to be created
imageName=aibWinImage
subscriptionID=<Your subscription ID>
az group create -n $imageResourceGroup -l $location
az role assignment create \
--assignee cf32a0cc-373c-47c9-9156-0db11f6a6dfc \
--role Contributor \
--scope /subscriptions/$subscriptionID/resourceGroups/$imageResourceGroup
Download the .json example
curl
https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquic
kstarts/0_Creating_a_Custom
_Windows_Managed_Image/helloImageTemplateWin.json -o helloImageTemplateWin.json
sed -i -e "s/<subscriptionID>/$subscriptionID/g" helloImageTemplateWin.json
sed -i -e "s/<rgName>/$imageResourceGroup/g" helloImageTemplateWin.json
sed -i -e "s/<region>/$location/g" helloImageTemplateWin.json
sed -i -e "s/<imageName>/$imageName/g" helloImageTemplateWin.json
sed -i -e "s/<runOutputName>/$runOutputName/g" helloImageTemplateWin.json
Create the image
az resource create \
--resource-group $imageResourceGroup \
--properties @helloImageTemplateWin.json \
--is-full-object \
--resource-type Microsoft.VirtualMachineImages/imageTemplates \
-n helloImageTemplateWin01
We will be using some pieces of information repeatedly, so we will create some
variables to store that information.
Create a variable for your subscription ID. You can get this using az account show
| grep id .
Create the resource group.
Give Image Builder permission to create resources in that resource group. The
--assignee value is the app
registration ID for the Image Builder service.
Download the example .json file and configure it with the variables you created.
Submit the image configuration to the VM Image Builder service
Start the image build.
az resource invoke-action \
--resource-group $imageResourceGroup \
--resource-type Microsoft.VirtualMachineImages/imageTemplates \
-n helloImageTemplateWin01 \
--action Run
Create the VM
az vm create \
--resource-group $imageResourceGroup \
--name aibImgWinVm00 \
--admin-username aibuser \
--admin-password <password> \
--image $imageName \
--location $location
Verify the customization
dir c:\
Clean up
az resource delete \
--resource-group $imageResourceGroup \
--resource-type Microsoft.VirtualMachineImages/imageTemplates \
-n helloImageTemplateWin01
az group delete -n $imageResourceGroup
Next steps
Wait until the build is complete. This can take about 15 minutes.
Create the VM using the image you built. Replace with your own password for the
aibuser on the VM.
Create a Remote Desktop connection to the VM using the username and password you
set when you created the
VM. Inside the VM, open a cmd prompt and type:
You should see these two directories created during image customization:
buildActions
buildArtifacts
When you are done, delete the resources.
To learn more about the components of the .json file used in this article, see
Image builder template reference.
Preview: Create a Windows image and distribute it to
a Shared Image Gallery
5/6/2019 � 4 minutes to read � Edit Online
IMPORTANT
Register the features
az feature register --namespace Microsoft.VirtualMachineImages --name
VirtualMachineTemplatePreview
az feature show --namespace Microsoft.VirtualMachineImages --name
VirtualMachineTemplatePreview | grep state
az provider show -n Microsoft.VirtualMachineImages | grep registrationState
az provider show -n Microsoft.Storage | grep registrationState
az provider show -n Microsoft.Compute | grep registrationState
az provider register -n Microsoft.VirtualMachineImages
az provider register -n Microsoft.Storage
az provider register -n Microsoft.Compute
Set variables and permissions
This article is to show you how you can use the Azure Image Builder to create an
image version in a Shared Image
Gallery, then distribute the image globally.
We will be using a .json template to configure the image. The .json file we are
using is here:
helloImageTemplateforWinSIG.json.
To distribute the image to a Shared Image Gallery, the template uses sharedImage as
the value for the distribute
section of the template.
Azure Image Builder is currently in public preview. This preview version is
provided without a service level agreement, and it's
not recommended for production workloads. Certain features might not be supported
or might have constrained capabilities.
For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
To use Azure Image Builder during the preview, you need to register the new
feature.
Check the status of the feature registration.
Check your registration.
If they do not say registered, run the following:
We will be using some pieces of information repeatedly, so we will create some
variables to store that information.
Replace the values for the variables, like username and vmpassword , with your own
information.
# Resource group name - we are using ibsigRG in this example
sigResourceGroup=myIBWinRG
# Datacenter location - we are using West US 2 in this example
location=westus
# Additional region to replicate the image to - we are using East US in this
example
additionalregion=eastus
# name of the shared image gallery - in this example we are using myGallery
sigName=my22stSIG
# name of the image definition to be created - in this example we are using
myImageDef
imageDefName=winSvrimages
# image distribution metadata reference name
runOutputName=w2019SigRo
# User name and password for the VM
username="azureuser"
vmpassword="passwordfortheVM"
subscriptionID="Subscription ID"
az group create -n $sigResourceGroup -l $location
az role assignment create \
--assignee cf32a0cc-373c-47c9-9156-0db11f6a6dfc \
--role Contributor \
--scope /subscriptions/$subscriptionID/resourceGroups/$sigResourceGroup
Create an image definition and gallery
az sig create \
-g $sigResourceGroup \
--gallery-name $sigName
az sig image-definition create \
-g $sigResourceGroup \
--gallery-name $sigName \
--gallery-image-definition $imageDefName \
--publisher corpIT \
--offer myOffer \
--sku 2019 \
--os-type Windows
Download and configure the .json
Create a variable for your subscription ID. You can get this using az account show
| grep id .
Create the resource group.
Give Azure Image Builder permission to create resources in that resource group. The
--assignee value is the app
registration ID for the Image Builder service.
Create an image gallery.
Create an image definition.
Download the .json template and configure it with your variables.
curl
https://raw.githubusercontent.com/danielsollondon/azvmimagebuilder/master/quickquic
kstarts/1_Creating_a_Custom_
Win_Shared_Image_Gallery_Image/helloImageTemplateforWinSIG.json -o
helloImageTemplateforWinSIG.json
sed -i -e "s/<subscriptionID>/$subscriptionID/g" helloImageTemplateforWinSIG.json
sed -i -e "s/<rgName>/$sigResourceGroup/g" helloImageTemplateforWinSIG.json
sed -i -e "s/<imageDefName>/$imageDefName/g" helloImageTemplateforWinSIG.json
sed -i -e "s/<sharedImageGalName>/$sigName/g" helloImageTemplateforWinSIG.json
sed -i -e "s/<region1>/$location/g" helloImageTemplateforWinSIG.json
sed -i -e "s/<region2>/$additionalregion/g" helloImageTemplateforWinSIG.json
sed -i -e "s/<runOutputName>/$runOutputName/g" helloImageTemplateforWinSIG.json
Create the image version
az resource create \
--resource-group $sigResourceGroup \
--properties @helloImageTemplateforWinSIG.json \
--is-full-object \
--resource-type Microsoft.VirtualMachineImages/imageTemplates \
-n helloImageTemplateforWinSIG01
az resource invoke-action \
--resource-group $sigResourceGroup \
--resource-type Microsoft.VirtualMachineImages/imageTemplates \
-n helloImageTemplateforWinSIG01 \
--action Run
Create the VM
az vm create \
--resource-group $sigResourceGroup \
--name aibImgWinVm001 \
--admin-username $username \
--admin-password $vmpassword \
--image
"/subscriptions/$subscriptionID/resourceGroups/
$sigResourceGroup/providers/Microsoft.Compute/galleries/$sigName
/images/$imageDefName/versions/latest" \
--location $location
Verify the customization
dir c:\
This next part will create the image version in the gallery.
Submit the image configuration to the Azure Image Builder service.
Start the image build.
Creating the image and replicating it to both regions can take a while. Wait until
this part is finished before moving
on to creating a VM.
Create a VM from the image version that was created by Azure Image Builder.
Create a Remote Desktop connection to the VM using the username and password you
set when you created the
VM. Inside the VM, open a cmd prompt and type:
Clean up resources
az resource delete \
--resource-group $sigResourceGroup \
--resource-type Microsoft.VirtualMachineImages/imageTemplates \
-n helloImageTemplateforWinSIG01
sigDefImgVersion=$(az sig image-version list \
-g $sigResourceGroup \
--gallery-name $sigName \
--gallery-image-definition $imageDefName \
--subscription $subscriptionID --query [].'name' -o json | grep 0. | tr -d '"')
az sig image-version delete \
-g $sigResourceGroup \
--gallery-image-version $sigDefImgVersion \
--gallery-name $sigName \
--gallery-image-definition $imageDefName \
--subscription $subscriptionID
az sig image-definition delete \
-g $sigResourceGroup \
--gallery-name $sigName \
--gallery-image-definition $imageDefName \
--subscription $subscriptionID
az sig delete -r $sigName -g $sigResourceGroup
az group delete -n $sigResourceGroup -y
Next Steps
You should see a directory named buildActions that was created during image
customization.
If you want to now try re-customizing the image version to create a new version of
the same image, skip this step
and go on to Use Azure Image Builder to create another image version.
This will delete the image that was created, along with all of the other resource
files. Make sure you are finished
with this deployment before deleting the resources.
When deleting image gallery resources, you need delete all of the image versions
before you can delete the image
definition used to create them. To delete a gallery, you first need to have deleted
all of the image definitions in the
gallery.
Delete the image builder template.
Get the image version created by image builder, this always starts with 0. , and
then delete the image version
Delete the image definition.
Delete the gallery.
Delete the resource group.
To learn how to update the image version you created, see Use Azure Image Builder
to create another image
version.