From 81806bb71d10ff81d26cb50f45cc9a880c815eeb Mon Sep 17 00:00:00 2001 From: naman-msft Date: Tue, 17 Dec 2024 20:39:25 -0800 Subject: [PATCH] updated prompt --- tools/README.md | 6 +- tools/ada.py | 20 ++-- tools/test.md | 275 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 286 insertions(+), 15 deletions(-) create mode 100644 tools/test.md diff --git a/tools/README.md b/tools/README.md index f1af424ca..e998af232 100644 --- a/tools/README.md +++ b/tools/README.md @@ -32,11 +32,7 @@ Welcome to Exec Docs Agent! This tool helps you convert documents and troublesho 3. Ensure you have the Azure OpenAI API key and GitHub access token set as environment variables: ```bash - export AZ - -URE - -_OPENAI_API_KEY= + export AZURE_OPENAI_API_KEY= export AZURE_OPENAI_ENDPOINT= export GitHub_Token= ``` diff --git a/tools/ada.py b/tools/ada.py index 0a9a6416c..b499d5a92 100644 --- a/tools/ada.py +++ b/tools/ada.py @@ -32,7 +32,7 @@ except pkg_resources.DistributionNotFound: subprocess.check_call([sys.executable, "-m", "pip", "install", package]) -system_prompt = f"""Exec Docs is a vehicle transforms standard markdown into interactive, executable learning content, allowing code commands within the document to be run step-by-step or “one-click”. This is powered by the Innovation Engine, an open-source CLI tool that powers the execution and testing of these markdown scripts and can integrate with automated CI/CD pipelines. You are an Exec Doc writing expert. You will either write a new exec doc from scratch if no doc is attached or update an existing one if it is attached. You must adhere to the following rules while presenting your output: +system_prompt = """Exec Docs is a vehicle transforms standard markdown into interactive, executable learning content, allowing code commands within the document to be run step-by-step or “one-click”. This is powered by the Innovation Engine, an open-source CLI tool that powers the execution and testing of these markdown scripts and can integrate with automated CI/CD pipelines. You are an Exec Doc writing expert. You will either write a new exec doc from scratch if no doc is attached or update an existing one if it is attached. You must adhere to the following rules while presenting your output: ### Prerequisites @@ -185,7 +185,7 @@ ```bash az account set --subscription "" ``` - - Run the command in the code block in cloudshell. If it returns an output that you would want Innovation Engine to verify, copy the output from the terminal and paste it in a new code block below the original code block. The way a result code block should be formatted has been shown below, in this case for the command `az group create --name "MyResourceGroup123" --location eastus`. + - Run the command in the code block in cloudshell. If it returns an output that you would want Innovation Engine to verify, copy the output from the terminal and paste it in a new code block below the original code block. The way a result code block should be formatted has been shown below, in this case for the command [az group create --name "MyResourceGroup123" --location eastus](http://_vscodecontentref_/1). **Example:** ```markdown @@ -194,17 +194,17 @@ ```JSON - { + {{ "id": "/subscriptions/abcabc-defdef-ghighi-jkljkl/resourceGroups/MyResourceGroup123", "location": "eastus", "managedBy": null, "name": "MyResourceGroup123", - "properties": { + "properties": {{ "provisioningState": "Succeeded" - }, + }}, "tags": null, "type": "Microsoft.Resources/resourceGroups" - } + }} ``` ``` - If you run into an error while executing a code block or the code block is running in an infinite loop, update the Exec Doc based on the error stack trace, restart/clear Cloudshell, and rerun the command block(s) from the start until you reach that command block. This is done to override any potential issues that may have occurred during the initial run. More guidance is given in the [FAQ section](#frequently-asked-questions-faqs) below. @@ -227,17 +227,17 @@ ```JSON - { + {{ "id": "/subscriptions/xxxxx-xxxxx-xxxxx-xxxxx/resourceGroups/MyResourceGroupxxx", "location": "eastus", "managedBy": null, "name": "MyResourceGroupxxx", - "properties": { + "properties": {{ "provisioningState": "Succeeded" - }, + }}, "tags": null, "type": "Microsoft.Resources/resourceGroups" - } + }} ``` ``` diff --git a/tools/test.md b/tools/test.md new file mode 100644 index 000000000..c15e746f2 --- /dev/null +++ b/tools/test.md @@ -0,0 +1,275 @@ +--- +title: 'Tutorial: Create & manage a Virtual Machine Scale Set – Azure CLI' +description: Learn how to use the Azure CLI to create a Virtual Machine Scale Set, along with some common management tasks such as how to start and stop an instance, or change the scale set capacity. +author: ju-shim +ms.author: jushiman +ms.topic: tutorial +ms.service: azure-virtual-machine-scale-sets +ms.date: 06/14/2024 +ms.reviewer: mimckitt +ms.custom: mimckitt, devx-track-azurecli +--- +# Tutorial: Create and manage a Virtual Machine Scale Set with the Azure CLI +A Virtual Machine Scale Set allows you to deploy and manage a set of virtual machines. Throughout the lifecycle of a Virtual Machine Scale Set, you may need to run one or more management tasks. In this tutorial you learn how to: + +> [!div class="checklist"] +> * Create a resource group +> * Create a Virtual Machine Scale Set +> * Scale out and in +> * Stop, Start and restart VM instances + +[!INCLUDE [quickstarts-free-trial-note](~/reusable-content/ce-skilling/azure/includes/quickstarts-free-trial-note.md)] + +[!INCLUDE [azure-cli-prepare-your-environment.md](~/reusable-content/azure-cli/azure-cli-prepare-your-environment.md)] + +This article requires version 2.0.29 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed. + +## Create a resource group +An Azure resource group is a logical container into which Azure resources are deployed and managed. A resource group must be created before a Virtual Machine Scale Set. Create a resource group with the [az group create](/cli/azure/group) command. In this example, a resource group named *myResourceGroup* is created in the *eastus* region. + +```azurecli-interactive +az group create --name myResourceGroup --location eastus +``` + +The resource group name is specified when you create or modify a scale set throughout this tutorial. + +## Create a scale set + +> [!IMPORTANT] +>Starting November 2023, VM scale sets created using PowerShell and Azure CLI will default to Flexible Orchestration Mode if no orchestration mode is specified. For more information about this change and what actions you should take, go to [Breaking Change for VMSS PowerShell/CLI Customers - Microsoft Community Hub]( +https://techcommunity.microsoft.com/t5/azure-compute-blog/breaking-change-for-vmss-powershell-cli-customers/ba-p/3818295) + +You create a Virtual Machine Scale Set with the [az vmss create](/cli/azure/vmss) command. The following example creates a scale set named *myScaleSet*, and generates SSH keys if they don't exist: + +```azurecli-interactive +az vmss create \ + --resource-group myResourceGroup \ + --name myScaleSet \ + --orchestration-mode flexible \ + --image \ + --admin-username azureuser \ + --generate-ssh-keys +``` + +It takes a few minutes to create and configure all the scale set resources and VM instances. To distribute traffic to the individual VM instances, a load balancer is also created. + +## View information about the VM instances in your scale set +To view a list of VM instances in a scale set, use [az vm list](/cli/azure/vm) as follows: + +```azurecli-interactive +az vm list --resource-group myResourceGroup --output table +``` + +The following example output shows two VM instances in the scale set: + +```output +Name ResourceGroup Location Zones +------------------- --------------- ---------- ------- +myScaleSet_instance1 myResourceGroup eastus +myScaleSet_instance2 myResourceGroup eastus +``` +To see additional information about a specific VM instance, use [az vm show](/cli/azure/vm) and specify the VM name. + +```azurecli-interactive +az vm show --resource-group myResourceGroup --name myScaleSet_instance1 +``` + +```output +{ + "hardwareProfile": { + "vmSize": "Standard_DS1_v2", + }, + "id": "/subscriptions/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myScaleSet_instance1", + "location": "eastus", + "name": "myScaleSet_instance1", + "networkProfile": { + "networkInterfaces": [ + { + "deleteOption": "Delete", + "id": "/subscriptions/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/mysca2215Nic-0396c71c", + "primary": true, + "resourceGroup": "myResourceGroup" + } + ] + }, + "osProfile": { + "adminUsername": "azureuser", + "allowExtensionOperations": true, + "computerName": "myScaleSN30BP1", + "linuxConfiguration": { + "disablePasswordAuthentication": true, + "enableVmAgentPlatformUpdates": false, + "patchSettings": { + "assessmentMode": "ImageDefault", + "patchMode": "ImageDefault" + }, + "provisionVmAgent": true, + "ssh": { + "publicKeys": [ + { + "keyData": "ssh-rsa", + "path": "/home/azureuser/.ssh/authorized_keys" + } + ] + } + }, + "requireGuestProvisionSignal": true, + "secrets": [], + }, + "provisioningState": "Succeeded", + "resourceGroup": "myResourceGroup", + "storageProfile": { + "dataDisks": [], + "imageReference": { + "exactVersion": "XXXXX", + "offer": "myOffer", + "publisher": "myPublisher", + "sku": "mySKU", + "version": "latest" + }, + "osDisk": { + "caching": "ReadWrite", + "createOption": "FromImage", + "deleteOption": "Delete", + "diskSizeGb": 30, + "managedDisk": { + "id": "/subscriptions/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myScaleSet_instance1_disk1", + "resourceGroup": "myResourceGroup", + "storageAccountType": "Premium_LRS" + }, + "name": "myScaleSet_instance1_disk1", + "osType": "Linux", + } + }, + "tags": {}, + "timeCreated": "2022-11-16T20:32:15.024581+00:00", + "type": "Microsoft.Compute/virtualMachines", + "virtualMachineScaleSet": { + "id": "/subscriptions/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/myScaleSet", + "resourceGroup": "myResourceGroup" + }, +} +``` + + +## Create a scale set with a specific VM instance size +When you created a scale set at the start of the tutorial, a default VM SKU of *Standard_D1_v2* was provided for the VM instances. You can specify a different VM instance size based on the output from [az vm list-sizes](/cli/azure/vm). The following example would create a scale set with the `--vm-sku` parameter to specify a VM instance size of *Standard_F1*. As it takes a few minutes to create and configure all the scale set resources and VM instances, you don't have to deploy the following scale set: + +```azurecli-interactive +az vmss create \ + --resource-group myResourceGroup \ + --name myScaleSet \ + --orchestration-mode flexible \ + --image \ + --vm-sku Standard_F1 \ + --admin-user azureuser \ + --generate-ssh-keys +``` + +## Change the capacity of a scale set +When you created a scale set at the start of the tutorial, two VM instances were deployed by default. You can specify the `--instance-count` parameter with [az vmss create](/cli/azure/vmss) to change the number of instances created with a scale set. To increase or decrease the number of VM instances in your existing scale set, you can manually change the capacity. The scale set creates or removes the required number of VM instances, then configures the load balancer to distribute traffic. + +To manually increase or decrease the number of VM instances in the scale set, use [az vmss scale](/cli/azure/vmss). The following example sets the number of VM instances in your scale set to *3*: + +```azurecli-interactive +az vmss scale \ + --resource-group myResourceGroup \ + --name myScaleSet \ + --new-capacity 3 +``` + +It takes a few minutes to update the capacity of your scale set. To see the number of instances you now have in the scale set, use [az vm list](/cli/azure/vmss) and query on the associated resource group. + +```azurecli-interactive +az vm list --resource-group myResourceGroup --output table +``` + +```output +Name ResourceGroup Location Zones +------------------- --------------- ---------- ------- +myScaleSet_instance1 myResourceGroup eastus +myScaleSet_instance2 myResourceGroup eastus +myScaleSet_instance3 myResourceGroup eastus +``` + +## Stop and deallocate VM instances in a scale set +To stop all the VM instances in a scale set, use [az vmss stop](/cli/azure/vmss). + +```azurecli-interactive +az vmss stop \ + --resource-group myResourceGroup \ + --name myScaleSet +``` + +To stop individual VM instances in a scale set, use [az vm stop](/cli/azure/vm) and specify the instance name. + +```azurecli-interactive +az vm stop \ + --resource-group myResourceGroup \ + --name myScaleSet_instance1 +``` + +Stopped VM instances remain allocated and continue to incur compute charges. If you instead wish the VM instances to be deallocated and only incur storage charges, use [az vm deallocate](/cli/azure/vm) and specify the instance names you want deallocated. + +```azurecli-interactive +az vm deallocate \ + --resource-group myResourceGroup \ + --name myScaleSet_instance1 +``` + +## Start VM instances in a scale set +To start all the VM instances in a scale set, use [az vmss start](/cli/azure/vmss). + +```azurecli-interactive +az vmss start \ + --resource-group myResourceGroup \ + --name myScaleSet +``` + +To start individual VM instances in a scale set, use [az vm start](/cli/azure/vm) and specify the instance name. + +```azurecli-interactive +az vm start \ + --resource-group myResourceGroup \ + --name myScaleSet_instance1 +``` + +## Restart VM instances in a scale set +To restart all the VM instances in a scale set, use [az vmss restart](/cli/azure/vmss). + +```azurecli-interactive +az vmss restart \ + --resource-group myResourceGroup \ + --name myScaleSet +``` + +To restart individual VM instances in a scale set, use [az vm restart](/cli/azure/vm) and specify the instance name. + +```azurecli-interactive +az vm restart \ + --resource-group myResourceGroup \ + --name myScaleSet_instance1 +``` + +## Clean up resources +When you delete a resource group, all resources contained within, such as the VM instances, virtual network, and disks, are also deleted. 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 an extra prompt to do so. + +```azurecli-interactive +az group delete --name myResourceGroup --no-wait --yes +``` + + +## Next steps +In this tutorial, you learned how to perform some basic scale set creation and management tasks with the Azure CLI: + +> [!div class="checklist"] +> * Create a resource group +> * Create a scale set +> * View and use specific VM sizes +> * Manually scale a scale set +> * Perform common scale set management tasks such as stopping, starting and restarting your scale set + +Advance to the next tutorial to learn how to connect to your scale set instances. + +> [!div class="nextstepaction"] +> [Use data disks with scale sets](tutorial-connect-to-instances-cli.md) \ No newline at end of file