Skip to content

Commit 435fa18

Browse files
authored
Update quickstart-create-azure-cli.md
1 parent 4608e7a commit 435fa18

File tree

1 file changed

+45
-46
lines changed

1 file changed

+45
-46
lines changed

articles/azure-compute-fleet/quickstart-create-azure-cli.md

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.topic: how-to
77
ms.service: azure-compute-fleet
88
ms.date: 05/09/2025
99
ms.reviewer: jushiman
10-
ms.custom: devx-track-arm-template, build-2024
10+
ms.custom: devx-track-azurecli
1111
---
1212

1313
# Create an Azure Compute Fleet using Azure CLI
@@ -24,68 +24,67 @@ This article steps through using an ARM template to create an Azure Compute Flee
2424
- Before using Compute Fleet, complete the feature registration and configure role-based access controls (RBAC).
2525

2626

27-
## Feature registration
27+
### Feature registration
2828

2929
Register the Azure Compute Fleet resource provider with your subscription using Azure CLI. Registration can take up to 30 minutes to successfully show as registered.
3030

3131
```bash
3232
az provider register --namespace 'Microsoft.AzureFleet'
3333
```
34+
### Set Environment variables
3435

35-
### [Azure portal](#tab/portal-1)
36-
37-
1. In the [Azure portal](https://portal.azure.com), navigate to your subscriptions.
38-
1. Select the subscription you want to enable Azure Compute Fleet on.
39-
1. Under **Settings**, select **Resource providers**.
40-
1. Search for *Microsoft.AzureFleet* and register the provider.
41-
42-
---
43-
44-
45-
## Role-based access control permissions
46-
47-
Assign the appropriate RBAC permissions to use Azure Compute Fleet.
48-
49-
1. In the [Azure portal](https://portal.azure.com), navigate to your subscriptions.
50-
1. Select the subscription you want to adjust RBAC permissions.
51-
1. Select **Access Control (IAM)**.
52-
1. Select *Add*, then **Add Role Assignment**.
53-
1. Search for **Virtual Machine Contributor** and highlight it. Select **Next**.
54-
1. Click on **+ Select Members**.
55-
1. Search for *Azure Fleet Resource Provider* role.
56-
1. Select the *Azure Fleet Resource Provider* and select **Review + Assign**.
57-
1. Repeat the previous steps for the *Network Contributor* role and the *Managed Identity Operator* role.
58-
59-
If you're using images stored in Compute Gallery when deploying your Compute Fleet, also repeat the previous steps for the *Compute Gallery Sharing Admin* role.
60-
61-
For more information on assigning roles, see [assign Azure roles using the Azure portal](../role-based-access-control/quickstart-assign-role-user-portal.md).
62-
63-
64-
## ARM template
36+
```bash
37+
export RANDOM_ID="$(openssl rand -hex 3)"
38+
export MY_RESOURCE_GROUP_NAME="myFleetResourceGroup$RANDOM_ID"
39+
export REGION=EastUS
40+
export MY_FLEET_NAME="myFLEET$RANDOM_ID"
41+
export MY_USERNAME=azureuser
42+
export MY_VNET_NAME="myVNet$RANDOM_ID"
43+
export NETWORK_PREFIX="$(($RANDOM % 254 + 1))"
44+
export MY_VNET_PREFIX="10.$NETWORK_PREFIX.0.0/16"
45+
export MY_VM_SN_NAME="myVMSN$RANDOM_ID"
46+
export MY_VM_SN_PREFIX="10.$NETWORK_PREFIX.0.0/24"
47+
```
6548

66-
[!INCLUDE [About Azure Resource Manager](~/reusable-content/ce-skilling/azure/includes/resource-manager-quickstart-introduction.md)]
49+
### Create a resource group
6750

68-
ARM templates let you deploy groups of related resources. In a single template, you can create the Virtual Machine Scale Set, install applications, and configure autoscale rules. With the use of variables and parameters, this template can be reused to update existing, or create extra scale sets. You can deploy templates through the Azure portal, Azure CLI, or Azure PowerShell, or from continuous integration / continuous delivery (CI/CD) pipelines.
51+
```bash
52+
az group create --name $MY_RESOURCE_GROUP_NAME --location $REGION
53+
```
6954

55+
### Create virtual network and subnet
7056

71-
## Review the template
57+
```bash
58+
az network vnet create --name $MY_VNET_NAME --resource-group $MY_RESOURCE_GROUP_NAME --location $REGION --address-prefix $MY_VNET_PREFIX --subnet-name $MY_VM_SN_NAME --subnet-prefix $MY_VM_SN_PREFIX
59+
```
7260

61+
Get the subnet ARM ID
7362

63+
```bash
64+
export MY_SUBNET_ID="$(az network vnet subnet show \
65+
--resource-group $MY_RESOURCE_GROUP_NAME \
66+
--vnet-name $MY_VNET_NAME \
67+
--name $MY_VM_SN_NAME \
68+
--query id --output tsv)"
69+
```
7470

75-
These resources are defined in the template:
71+
### Set up the admin password
7672

77-
- [**Microsoft.Network/virtualNetworks**](/azure/templates/microsoft.network/virtualnetworks)
78-
- [**Microsoft.Network/loadBalancers**](/azure/templates/microsoft.network/loadbalancers)
73+
Setup a password that meets the [password requirements for Azure VMs](https://learn.microsoft.com/en-us/azure/virtual-machines/windows/faq#what-are-the-password-requirements-when-creating-a-vm-).
7974

75+
export ADMIN_PASSWORD="<azure compliant password>"
8076

81-
## Clean up resources
8277

83-
When no longer needed, you can use [az group delete](/cli/azure/group) to remove the resource group, scale set, and all related resources as follows. The `--no-wait` parameter returns control to the prompt without waiting for the operation to complete. The `--yes` parameter confirms that you wish to delete the resources without another prompt to do so.
78+
### Create Compute Fleet
8479

85-
```azurecli-interactive
86-
az group delete --name myResourceGroup --yes --no-wait
80+
```bash
81+
export COMPUTE_PROFILE="{ 'baseVirtualMachineProfile': { 'storageProfile': { 'imageReference': { 'publisher':'canonical', 'offer':'0001-com-ubuntu-server-focal', 'sku': '20_04-lts-gen2', 'version': 'latest' } }, 'osProfile': { 'computerNamePrefix': 'vm', 'adminUsername': '$MY_USERNAME', 'adminPassword': '$ADMIN_PASSWORD'}, 'networkProfile': { 'networkInterfaceConfigurations': [{ 'name': 'nic', 'primary': 'true', 'enableIPForwarding': 'true', 'ipConfigurations': [{ 'name': 'ipc', 'subnet': { 'id': '$MY_SUBNET_ID' } }] }], 'networkApiVersion': '2020-11-01'} } }"
82+
```
83+
84+
```bash
85+
az compute-fleet create --name $MY_FLEET_NAME --resource-group $MY_RESOURCE_GROUP_NAME --location $REGION \
86+
--spot-priority-profile "{ 'capacity': 5 }" \
87+
--regular-priority-profile "{ 'capacity': 5 }" \
88+
--compute-profile "$COMPUTE_PROFILE" \
89+
--vm-sizes-profile "[{ 'name': 'Standard_F1s' }]"
8790
```
88-
89-
## Next steps
90-
> [!div class="nextstepaction"]
91-
> [Create an Azure Compute Fleet with Azure portal.](quickstart-create-portal.md)

0 commit comments

Comments
 (0)