Skapar eller uppdaterar en disk.
	
		PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}?api-version=2025-01-02
		URI-parametrar
		
			
				| Name | 
				I | 
				Obligatorisk | 
				Typ | 
				Description | 
			
				
					| 
						 diskName 
					 | 
					path | 
					
							True
					 | 
					
			 
					string
			 
	
					 | 
					
						 Namnet på den hanterade disk som skapas. Det går inte att ändra namnet när disken har skapats. Tecken som stöds för namnet är a-z, A-Z, 0-9, _ och -. Maximal namnlängd är 80 tecken. 
					 | 
				
				
					| 
						 resourceGroupName 
					 | 
					path | 
					
							True
					 | 
					
			 
					string
			 
	minLength: 1 maxLength: 90
					 | 
					
						 Namnet på resursgruppen. Namnet är skiftlägesokänsligt. 
					 | 
				
				
					| 
						 subscriptionId 
					 | 
					path | 
					
							True
					 | 
					
			 
					string
			 
	minLength: 1
					 | 
					
						 ID för målprenumerationen. 
					 | 
				
				
					| 
						 api-version 
					 | 
					query | 
					
							True
					 | 
					
			 
					string
			 
	minLength: 1
					 | 
					
						 Den API-version som ska användas för den här åtgärden. 
					 | 
				
		
		Begärandetext
			
			
				
					| Name | 
					Obligatorisk | 
					Typ | 
					Description | 
				
	| 
		location
	 | 
	
			True
	 | 
	
			 
					string
			 
	
	 | 
	
		 Den geo-plats där resursen finns 
	 | 
	| 
		properties.creationData
	 | 
	
			True
	 | 
	
			 
					CreationData
			 
	
	 | 
	
		 Information om diskkälla. CreationData-information kan inte ändras när disken har skapats. 
	 | 
	| 
		extendedLocation
	 | 
	
	 | 
	
			 
					ExtendedLocation
			 
	
	 | 
	
		 Den utökade platsen där disken ska skapas. Det går inte att ändra den utökade platsen. 
	 | 
	| 
		properties.availabilityPolicy
	 | 
	
	 | 
	
			 
					AvailabilityPolicy
			 
	
	 | 
	
		 Avgör hur plattformen behandlar diskfel 
	 | 
	| 
		properties.burstingEnabled
	 | 
	
	 | 
	
			 
					boolean
			 
	
	 | 
	
		 Ställ in på true för att aktivera burst-prestanda utöver diskens etablerade prestandamål. Bursting är inaktiverat som standard. Gäller inte för Ultra-diskar. 
	 | 
	| 
		properties.completionPercent
	 | 
	
	 | 
	
			 
					number
(float)
			 
	
	 | 
	
		 Procent färdigt för bakgrundskopian när en resurs skapas via åtgärden CopyStart. 
	 | 
	| 
		properties.dataAccessAuthMode
	 | 
	
	 | 
	
			 
					DataAccessAuthMode
			 
	
	 | 
	
		 Ytterligare autentiseringskrav vid export eller uppladdning till en disk eller ögonblicksbild. 
	 | 
	| 
		properties.diskAccessId
	 | 
	
	 | 
	
			 
					string
			 
	
	 | 
	
		 ARM-ID för DiskAccess-resursen för användning av privata slutpunkter på diskar. 
	 | 
	| 
		properties.diskIOPSReadOnly
	 | 
	
	 | 
	
			 
					integer
(int64)
			 
	
	 | 
	
		 Det totala antalet IOPS som tillåts för alla virtuella datorer som monterar den delade disken som ReadOnly. En åtgärd kan överföra mellan 4k och 256 000 byte. 
	 | 
	| 
		properties.diskIOPSReadWrite
	 | 
	
	 | 
	
			 
					integer
(int64)
			 
	
	 | 
	
		 Antalet tillåtna IOPS för den här disken. kan endast användas för UltraSSD-diskar. En åtgärd kan överföra mellan 4k och 256 000 byte. 
	 | 
	| 
		properties.diskMBpsReadOnly
	 | 
	
	 | 
	
			 
					integer
(int64)
			 
	
	 | 
	
		 Det totala dataflödet (Mbit/s) som tillåts för alla virtuella datorer som monterar den delade disken som ReadOnly. Mbit/s innebär miljontals byte per sekund – MB använder här ISO-notationen, med krafter på 10. 
	 | 
	| 
		properties.diskMBpsReadWrite
	 | 
	
	 | 
	
			 
					integer
(int64)
			 
	
	 | 
	
		 Den bandbredd som tillåts för den här disken. kan endast användas för UltraSSD-diskar. Mbit/s innebär miljontals byte per sekund – MB använder här ISO-notationen, med krafter på 10. 
	 | 
	| 
		properties.diskSizeGB
	 | 
	
	 | 
	
			 
					integer
(int32)
			 
	
	 | 
	
		 Om creationData.createOption är Tomt är det här fältet obligatoriskt och anger storleken på disken som ska skapas. Om det här fältet finns för uppdateringar eller skapande med andra alternativ, anger det en storleksändring. Storleksändring tillåts endast om disken inte är ansluten till en virtuell dator som körs och bara kan öka diskens storlek. 
	 | 
	| 
		properties.encryption
	 | 
	
	 | 
	
			 
					Encryption
			 
	
	 | 
	
		 Krypteringsegenskapen kan användas för att kryptera vilande data med kundhanterade nycklar eller plattformshanterade nycklar. 
	 | 
	| 
		properties.encryptionSettingsCollection
	 | 
	
	 | 
	
			 
					EncryptionSettingsCollection
			 
	
	 | 
	
		 Krypteringsinställningar som används för Azure Disk Encryption kan innehålla flera krypteringsinställningar per disk eller ögonblicksbild. 
	 | 
	| 
		properties.hyperVGeneration
	 | 
	
	 | 
	
			 
					HyperVGeneration
			 
	
	 | 
	
		 Hypervisor-genereringen av den virtuella datorn. Gäller endast os-diskar. 
	 | 
	| 
		properties.maxShares
	 | 
	
	 | 
	
			 
					integer
(int32)
			 
	
	 | 
	
		 Det maximala antalet virtuella datorer som kan anslutas till disken samtidigt. Värdet större än ett anger en disk som kan monteras på flera virtuella datorer samtidigt. 
	 | 
	| 
		properties.networkAccessPolicy
	 | 
	
	 | 
	
			 
					NetworkAccessPolicy
			 
	
	 | 
	
		 Princip för åtkomst till disken via nätverk. 
	 | 
	| 
		properties.optimizedForFrequentAttach
	 | 
	
	 | 
	
			 
					boolean
			 
	
	 | 
	
		 Om du ställer in den här egenskapen på true förbättras tillförlitligheten och prestandan för datadiskar som ofta (mer än 5 gånger om dagen) kopplas från en virtuell dator och kopplas till en annan. Den här egenskapen bör inte anges för diskar som inte kopplas från och ansluts ofta eftersom det gör att diskarna inte överensstämmer med feldomänen för den virtuella datorn. 
	 | 
	| 
		properties.osType
	 | 
	
	 | 
	
			 
					OperatingSystemTypes
			 
	
	 | 
	
		 Typ av operativsystem. 
	 | 
	| 
		properties.publicNetworkAccess
	 | 
	
	 | 
	
			 
					PublicNetworkAccess
			 
	
	 | 
	
		 Princip för att kontrollera exporten på disken. 
	 | 
	| 
		properties.purchasePlan
	 | 
	
	 | 
	
			 
					DiskPurchasePlan
			 
	
	 | 
	
		 Köp planinformation för avbildningen från vilken OS-disken skapades. Till exempel - {name: 2019-Datacenter, utgivare: MicrosoftWindowsServer, produkt: WindowsServer} 
	 | 
	| 
		properties.securityProfile
	 | 
	
	 | 
	
			 
					DiskSecurityProfile
			 
	
	 | 
	
		 Innehåller säkerhetsrelaterad information för resursen. 
	 | 
	| 
		properties.supportedCapabilities
	 | 
	
	 | 
	
			 
					SupportedCapabilities
			 
	
	 | 
	
		 Lista över funktioner som stöds för avbildningen från vilken OS-disken skapades. 
	 | 
	| 
		properties.supportsHibernation
	 | 
	
	 | 
	
			 
					boolean
			 
	
	 | 
	
		 Anger att operativsystemet på en disk stöder viloläge. 
	 | 
	| 
		properties.tier
	 | 
	
	 | 
	
			 
					string
			 
	
	 | 
	
		 Prestandanivån för disken (t.ex. P4, S10) enligt beskrivningen här: https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Gäller inte för Ultra-diskar. 
	 | 
	| 
		sku
	 | 
	
	 | 
	
			 
					DiskSku
			 
	
	 | 
	
		 SKU-namnet för diskarna. Kan vara Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, StandardSSD_ZRS eller PremiumV2_LRS. 
	 | 
	| 
		tags
	 | 
	
	 | 
	
			 
					object
			 
	
	 | 
	
		 Resursetiketter. 
	 | 
	| 
		zones
	 | 
	
	 | 
	
			 
					string[]
			 
	
	 | 
	
		 Listan Logisk zon för Disk. 
	 | 
			
		Svar
		
			
				| Name | 
				Typ | 
				Description | 
			
	| 
		200 OK
	 | 
		
			 
					Disk
			 
	
		 | 
	
		 Uppdateringsåtgärden för resursdisken lyckades 
	 | 
	| 
		202 Accepted
	 | 
		
			 
					Disk
			 
	
		 | 
	
		 Begäran har godkänts för behandling, men bearbetningen har ännu inte slutförts. 
			Sidhuvuden 
				
					- Location: string
 
					- Retry-After: integer
 
				 
	 | 
	| 
		Other Status Codes
	 | 
		
			 
					CloudError
			 
	
		 | 
	
		 Ett oväntat felsvar. 
	 | 
		
		Säkerhet
			azure_auth
			Azure Active Directory OAuth2-flöde.
			
					Typ: 
					oauth2
					Flow: 
					implicit
					Auktoriseringswebbadress: 
					https://login.microsoftonline.com/common/oauth2/authorize
			
				Omfattningar
				
					
						| Name | 
						Description | 
					
						
							| 
								user_impersonation
							 | 
							
								personifiera ditt användarkonto
							 | 
						
				
		Exempel
			
				create a confidential VM supported disk encrypted with customer managed key
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "osType": "Windows",
    "securityProfile": {
      "securityType": "ConfidentialVM_DiskEncryptedWithCustomerKey",
      "secureVMDiskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"
    },
    "creationData": {
      "createOption": "FromImage",
      "imageReference": {
        "id": "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"
      }
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.DiskSecurityProfile;
import com.azure.resourcemanager.compute.models.DiskSecurityTypes;
import com.azure.resourcemanager.compute.models.ImageDiskReference;
import com.azure.resourcemanager.compute.models.OperatingSystemTypes;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_ConfidentialVMSupportedDiskEncryptedWithCMK.json
     */
    /**
     * Sample code: create a confidential VM supported disk encrypted with customer managed key.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAConfidentialVMSupportedDiskEncryptedWithCustomerManagedKey(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US").withOsType(OperatingSystemTypes.WINDOWS)
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.FROM_IMAGE)
                    .withImageReference(new ImageDiskReference().withId(
                        "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0")))
                .withSecurityProfile(new DiskSecurityProfile()
                    .withSecurityType(DiskSecurityTypes.CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_CUSTOMER_KEY)
                    .withSecureVMDiskEncryptionSetId(
                        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}")),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_confidential_vm_supported_disk_encrypted_with_cmk.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscriptionId}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {
                    "createOption": "FromImage",
                    "imageReference": {
                        "id": "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"
                    },
                },
                "osType": "Windows",
                "securityProfile": {
                    "secureVMDiskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}",
                    "securityType": "ConfidentialVM_DiskEncryptedWithCustomerKey",
                },
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ConfidentialVMSupportedDiskEncryptedWithCMK.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ConfidentialVMSupportedDiskEncryptedWithCMK.json
func ExampleDisksClient_BeginCreateOrUpdate_createAConfidentialVmSupportedDiskEncryptedWithCustomerManagedKey() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionFromImage),
				ImageReference: &armcompute.ImageDiskReference{
					ID: to.Ptr("/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"),
				},
			},
			OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
			SecurityProfile: &armcompute.DiskSecurityProfile{
				SecureVMDiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"),
				SecurityType:                to.Ptr(armcompute.DiskSecurityTypesConfidentialVMDiskEncryptedWithCustomerKey),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionFromImage),
	// 			ImageReference: &armcompute.ImageDiskReference{
	// 				ID: to.Ptr("/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"),
	// 			},
	// 		},
	// 		OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 		SecurityProfile: &armcompute.DiskSecurityProfile{
	// 			SecureVMDiskEncryptionSetID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"),
	// 			SecurityType: to.Ptr(armcompute.DiskSecurityTypesConfidentialVMDiskEncryptedWithCustomerKey),
	// 		},
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ConfidentialVMSupportedDiskEncryptedWithCMK.json
 */
async function createAConfidentialVMSupportedDiskEncryptedWithCustomerManagedKey() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscriptionId}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: {
      createOption: "FromImage",
      imageReference: {
        id: "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0",
      },
    },
    location: "West US",
    osType: "Windows",
    securityProfile: {
      secureVMDiskEncryptionSetId:
        "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}",
      securityType: "ConfidentialVM_DiskEncryptedWithCustomerKey",
    },
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ConfidentialVMSupportedDiskEncryptedWithCMK.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscriptionId}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    OSType = SupportedOperatingSystemType.Windows,
    CreationData = new DiskCreationData(DiskCreateOption.FromImage)
    {
        ImageReference = new ImageDiskReference
        {
            Id = new ResourceIdentifier("/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"),
        },
    },
    SecurityProfile = new DiskSecurityProfile
    {
        SecurityType = DiskSecurityType.ConfidentialVmDiskEncryptedWithCustomerKey,
        SecureVmDiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"),
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Succeeded",
    "osType": "Windows",
    "securityProfile": {
      "securityType": "ConfidentialVM_DiskEncryptedWithCustomerKey",
      "secureVMDiskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"
    },
    "creationData": {
      "createOption": "FromImage",
      "imageReference": {
        "id": "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"
      }
    }
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Updating",
    "osType": "Windows",
    "securityProfile": {
      "securityType": "ConfidentialVM_DiskEncryptedWithCustomerKey",
      "secureVMDiskEncryptionSetId": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"
    },
    "creationData": {
      "createOption": "FromImage",
      "imageReference": {
        "id": "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"
      }
    }
  }
}
				 
				create a managed disk and associate with disk access resource.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "networkAccessPolicy": "AllowPrivate",
    "diskAccessId": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskAccesses/{existing-diskAccess-name}"
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.NetworkAccessPolicy;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_WithDiskAccess.json
     */
    /**
     * Sample code: create a managed disk and associate with disk access resource.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void
        createAManagedDiskAndAssociateWithDiskAccessResource(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US")
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.EMPTY)).withDiskSizeGB(200)
                .withNetworkAccessPolicy(NetworkAccessPolicy.ALLOW_PRIVATE).withDiskAccessId(
                    "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskAccesses/{existing-diskAccess-name}"),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_with_disk_access.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {"createOption": "Empty"},
                "diskAccessId": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskAccesses/{existing-diskAccess-name}",
                "diskSizeGB": 200,
                "networkAccessPolicy": "AllowPrivate",
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithDiskAccess.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithDiskAccess.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskAndAssociateWithDiskAccessResource() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
			},
			DiskAccessID:        to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskAccesses/{existing-diskAccess-name}"),
			DiskSizeGB:          to.Ptr[int32](200),
			NetworkAccessPolicy: to.Ptr(armcompute.NetworkAccessPolicyAllowPrivate),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
	// 		},
	// 		DiskAccessID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskAccesses/{existing-diskAccess-name}"),
	// 		DiskSizeGB: to.Ptr[int32](200),
	// 		NetworkAccessPolicy: to.Ptr(armcompute.NetworkAccessPolicyAllowPrivate),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 		PublicNetworkAccess: to.Ptr(armcompute.PublicNetworkAccessEnabled),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithDiskAccess.json
 */
async function createAManagedDiskAndAssociateWithDiskAccessResource() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: { createOption: "Empty" },
    diskAccessId:
      "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskAccesses/{existing-diskAccess-name}",
    diskSizeGB: 200,
    location: "West US",
    networkAccessPolicy: "AllowPrivate",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithDiskAccess.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    CreationData = new DiskCreationData(DiskCreateOption.Empty),
    DiskSizeGB = 200,
    NetworkAccessPolicy = NetworkAccessPolicy.AllowPrivate,
    DiskAccessId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskAccesses/{existing-diskAccess-name}"),
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Succeeded",
    "networkAccessPolicy": "AllowPrivate",
    "diskAccessId": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskAccesses/{existing-diskAccess-name}",
    "publicNetworkAccess": "Enabled"
  },
  "location": "West US",
  "name": "myDisk"
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk"
}
				 
				create a managed disk and associate with disk encryption set.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "encryption": {
      "diskEncryptionSetId": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.Encryption;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_WithDiskEncryptionSet.json
     */
    /**
     * Sample code: create a managed disk and associate with disk encryption set.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void
        createAManagedDiskAndAssociateWithDiskEncryptionSet(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US")
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.EMPTY)).withDiskSizeGB(200)
                .withEncryption(new Encryption().withDiskEncryptionSetId(
                    "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}")),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_with_disk_encryption_set.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {"createOption": "Empty"},
                "diskSizeGB": 200,
                "encryption": {
                    "diskEncryptionSetId": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
                },
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithDiskEncryptionSet.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithDiskEncryptionSet.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskAndAssociateWithDiskEncryptionSet() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
			},
			DiskSizeGB: to.Ptr[int32](200),
			Encryption: &armcompute.Encryption{
				DiskEncryptionSetID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
	// 		},
	// 		DiskSizeGB: to.Ptr[int32](200),
	// 		Encryption: &armcompute.Encryption{
	// 			DiskEncryptionSetID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
	// 		},
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithDiskEncryptionSet.json
 */
async function createAManagedDiskAndAssociateWithDiskEncryptionSet() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: { createOption: "Empty" },
    diskSizeGB: 200,
    encryption: {
      diskEncryptionSetId:
        "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}",
    },
    location: "West US",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithDiskEncryptionSet.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    CreationData = new DiskCreationData(DiskCreateOption.Empty),
    DiskSizeGB = 200,
    Encryption = new DiskEncryption
    {
        DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"),
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Succeeded",
    "encryption": {
      "diskEncryptionSetId": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"
    }
  },
  "location": "West US",
  "name": "myDisk"
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk"
}
				 
				create a managed disk by copying a snapshot.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "creationData": {
      "createOption": "Copy",
      "sourceResourceId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot"
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_ByCopyingASnapshot.json
     */
    /**
     * Sample code: create a managed disk by copying a snapshot.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedDiskByCopyingASnapshot(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US")
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.COPY).withSourceResourceId(
                    "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot")),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_by_copying_asnapshot.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {
                    "createOption": "Copy",
                    "sourceResourceId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot",
                }
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ByCopyingASnapshot.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ByCopyingASnapshot.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskByCopyingASnapshot() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption:     to.Ptr(armcompute.DiskCreateOptionCopy),
				SourceResourceID: to.Ptr("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot"),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionCopy),
	// 			SourceResourceID: to.Ptr("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot"),
	// 		},
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ByCopyingASnapshot.json
 */
async function createAManagedDiskByCopyingASnapshot() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: {
      createOption: "Copy",
      sourceResourceId:
        "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot",
    },
    location: "West US",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ByCopyingASnapshot.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    CreationData = new DiskCreationData(DiskCreateOption.Copy)
    {
        SourceResourceId = new ResourceIdentifier("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot"),
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Updating",
    "creationData": {
      "createOption": "Copy",
      "sourceResourceId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot"
    }
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Updating",
    "creationData": {
      "createOption": "Copy",
      "sourceResourceId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot"
    }
  }
}
				 
				create a managed disk by importing an unmanaged blob from a different subscription.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "creationData": {
      "createOption": "Import",
      "storageAccountId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
      "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_ByImportingBlobFromADifferentSubscription.json
     */
    /**
     * Sample code: create a managed disk by importing an unmanaged blob from a different subscription.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedDiskByImportingAnUnmanagedBlobFromADifferentSubscription(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US")
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.IMPORT).withStorageAccountId(
                    "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount")
                    .withSourceUri("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd")),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_by_importing_blob_from_adifferent_subscription.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {
                    "createOption": "Import",
                    "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
                    "storageAccountId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
                }
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ByImportingBlobFromADifferentSubscription.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ByImportingBlobFromADifferentSubscription.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskByImportingAnUnmanagedBlobFromADifferentSubscription() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption:     to.Ptr(armcompute.DiskCreateOptionImport),
				SourceURI:        to.Ptr("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"),
				StorageAccountID: to.Ptr("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount"),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionImport),
	// 			SourceURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"),
	// 			StorageAccountID: to.Ptr("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount"),
	// 		},
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ByImportingBlobFromADifferentSubscription.json
 */
async function createAManagedDiskByImportingAnUnmanagedBlobFromADifferentSubscription() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: {
      createOption: "Import",
      sourceUri: "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
      storageAccountId:
        "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
    },
    location: "West US",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ByImportingBlobFromADifferentSubscription.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    CreationData = new DiskCreationData(DiskCreateOption.Import)
    {
        StorageAccountId = new ResourceIdentifier("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount"),
        SourceUri = new Uri("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"),
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Updating",
    "creationData": {
      "createOption": "Import",
      "storageAccountId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
      "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"
    }
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Updating",
    "creationData": {
      "createOption": "Import",
      "storageAccountId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
      "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"
    }
  }
}
				 
				create a managed disk by importing an unmanaged blob from the same subscription.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "creationData": {
      "createOption": "Import",
      "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_ByImportingBlobFromTheSameSubscription.json
     */
    /**
     * Sample code: create a managed disk by importing an unmanaged blob from the same subscription.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedDiskByImportingAnUnmanagedBlobFromTheSameSubscription(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US")
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.IMPORT)
                    .withSourceUri("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd")),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_by_importing_blob_from_the_same_subscription.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {
                    "createOption": "Import",
                    "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
                }
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ByImportingBlobFromTheSameSubscription.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ByImportingBlobFromTheSameSubscription.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskByImportingAnUnmanagedBlobFromTheSameSubscription() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionImport),
				SourceURI:    to.Ptr("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionImport),
	// 			SourceURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"),
	// 		},
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ByImportingBlobFromTheSameSubscription.json
 */
async function createAManagedDiskByImportingAnUnmanagedBlobFromTheSameSubscription() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: {
      createOption: "Import",
      sourceUri: "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
    },
    location: "West US",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_ByImportingBlobFromTheSameSubscription.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    CreationData = new DiskCreationData(DiskCreateOption.Import)
    {
        SourceUri = new Uri("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"),
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Updating",
    "creationData": {
      "createOption": "Import",
      "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"
    }
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Updating",
    "creationData": {
      "createOption": "Import",
      "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"
    }
  }
}
				 
				
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "osType": "Windows",
    "creationData": {
      "createOption": "FromImage",
      "imageReference": {
        "id": "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"
      }
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.ImageDiskReference;
import com.azure.resourcemanager.compute.models.OperatingSystemTypes;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_FromAPlatformImage.json
     */
    /**
     * Sample code: create a managed disk from a platform image.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedDiskFromAPlatformImage(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US").withOsType(OperatingSystemTypes.WINDOWS)
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.FROM_IMAGE)
                    .withImageReference(new ImageDiskReference().withId(
                        "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"))),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_from_aplatform_image.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscriptionId}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {
                    "createOption": "FromImage",
                    "imageReference": {
                        "id": "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"
                    },
                },
                "osType": "Windows",
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAPlatformImage.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAPlatformImage.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskFromAPlatformImage() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionFromImage),
				ImageReference: &armcompute.ImageDiskReference{
					ID: to.Ptr("/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"),
				},
			},
			OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionFromImage),
	// 			ImageReference: &armcompute.ImageDiskReference{
	// 				ID: to.Ptr("/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"),
	// 			},
	// 		},
	// 		HyperVGeneration: to.Ptr(armcompute.HyperVGenerationV1),
	// 		OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 		PurchasePlan: &armcompute.DiskPurchasePlan{
	// 			Name: to.Ptr("{sku}"),
	// 			Product: to.Ptr("{offer}"),
	// 			Publisher: to.Ptr("{publisher}"),
	// 		},
	// 		SupportedCapabilities: &armcompute.SupportedCapabilities{
	// 			AcceleratedNetwork: to.Ptr(true),
	// 		},
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAPlatformImage.json
 */
async function createAManagedDiskFromAPlatformImage() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscriptionId}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: {
      createOption: "FromImage",
      imageReference: {
        id: "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0",
      },
    },
    location: "West US",
    osType: "Windows",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAPlatformImage.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscriptionId}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    OSType = SupportedOperatingSystemType.Windows,
    CreationData = new DiskCreationData(DiskCreateOption.FromImage)
    {
        ImageReference = new ImageDiskReference
        {
            Id = new ResourceIdentifier("/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"),
        },
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Succeeded",
    "osType": "Windows",
    "hyperVGeneration": "V1",
    "purchasePlan": {
      "name": "{sku}",
      "publisher": "{publisher}",
      "product": "{offer}"
    },
    "supportedCapabilities": {
      "acceleratedNetwork": true
    },
    "creationData": {
      "createOption": "FromImage",
      "imageReference": {
        "id": "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"
      }
    }
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "osType": "Windows",
    "hyperVGeneration": "V1",
    "purchasePlan": {
      "name": "{sku}",
      "publisher": "{publisher}",
      "product": "{offer}"
    },
    "supportedCapabilities": {
      "acceleratedNetwork": true
    },
    "creationData": {
      "createOption": "FromImage",
      "imageReference": {
        "id": "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"
      }
    },
    "provisioningState": "Updating"
  }
}
				 
				
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "osType": "Windows",
    "creationData": {
      "createOption": "FromImage",
      "galleryImageReference": {
        "communityGalleryImageId": "/CommunityGalleries/{communityGalleryPublicGalleryName}/Images/{imageName}/Versions/1.0.0"
      }
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.ImageDiskReference;
import com.azure.resourcemanager.compute.models.OperatingSystemTypes;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_FromAnAzureComputeGalleryCommunityImage.json
     */
    /**
     * Sample code: create a managed disk from an Azure Compute Gallery community image.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedDiskFromAnAzureComputeGalleryCommunityImage(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US").withOsType(OperatingSystemTypes.WINDOWS)
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.FROM_IMAGE)
                    .withGalleryImageReference(new ImageDiskReference().withCommunityGalleryImageId(
                        "/CommunityGalleries/{communityGalleryPublicGalleryName}/Images/{imageName}/Versions/1.0.0"))),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_from_an_azure_compute_gallery_community_image.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscriptionId}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {
                    "createOption": "FromImage",
                    "galleryImageReference": {
                        "communityGalleryImageId": "/CommunityGalleries/{communityGalleryPublicGalleryName}/Images/{imageName}/Versions/1.0.0"
                    },
                },
                "osType": "Windows",
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryCommunityImage.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryCommunityImage.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskFromAnAzureComputeGalleryCommunityImage() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionFromImage),
				GalleryImageReference: &armcompute.ImageDiskReference{
					CommunityGalleryImageID: to.Ptr("/CommunityGalleries/{communityGalleryPublicGalleryName}/Images/{imageName}/Versions/1.0.0"),
				},
			},
			OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionFromImage),
	// 			GalleryImageReference: &armcompute.ImageDiskReference{
	// 				CommunityGalleryImageID: to.Ptr("/CommunityGalleries/{communityGalleryPublicGalleryName}/Images/{imageName}/Versions/1.0.0"),
	// 			},
	// 		},
	// 		HyperVGeneration: to.Ptr(armcompute.HyperVGenerationV1),
	// 		OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 		SupportedCapabilities: &armcompute.SupportedCapabilities{
	// 			AcceleratedNetwork: to.Ptr(true),
	// 		},
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryCommunityImage.json
 */
async function createAManagedDiskFromAnAzureComputeGalleryCommunityImage() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscriptionId}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: {
      createOption: "FromImage",
      galleryImageReference: {
        communityGalleryImageId:
          "/CommunityGalleries/{communityGalleryPublicGalleryName}/Images/{imageName}/Versions/1.0.0",
      },
    },
    location: "West US",
    osType: "Windows",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryCommunityImage.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscriptionId}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    OSType = SupportedOperatingSystemType.Windows,
    CreationData = new DiskCreationData(DiskCreateOption.FromImage)
    {
        GalleryImageReference = new ImageDiskReference
        {
            CommunityGalleryImageId = "/CommunityGalleries/{communityGalleryPublicGalleryName}/Images/{imageName}/Versions/1.0.0",
        },
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Succeeded",
    "osType": "Windows",
    "hyperVGeneration": "V1",
    "supportedCapabilities": {
      "acceleratedNetwork": true
    },
    "creationData": {
      "createOption": "FromImage",
      "galleryImageReference": {
        "communityGalleryImageId": "/CommunityGalleries/{communityGalleryPublicGalleryName}/Images/{imageName}/Versions/1.0.0"
      }
    }
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "osType": "Windows",
    "hyperVGeneration": "V1",
    "supportedCapabilities": {
      "acceleratedNetwork": true
    },
    "creationData": {
      "createOption": "FromImage",
      "galleryImageReference": {
        "communityGalleryImageId": "/CommunityGalleries/{communityGalleryPublicGalleryName}/Images/{imageName}/Versions/1.0.0"
      }
    },
    "provisioningState": "Updating"
  }
}
				 
				create a managed disk from an Azure Compute Gallery direct shared image.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "osType": "Windows",
    "creationData": {
      "createOption": "FromImage",
      "galleryImageReference": {
        "sharedGalleryImageId": "/SharedGalleries/{sharedGalleryUniqueName}/Images/{imageName}/Versions/1.0.0"
      }
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.ImageDiskReference;
import com.azure.resourcemanager.compute.models.OperatingSystemTypes;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_FromAnAzureComputeGalleryDirectSharedImage.json
     */
    /**
     * Sample code: create a managed disk from an Azure Compute Gallery direct shared image.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedDiskFromAnAzureComputeGalleryDirectSharedImage(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US").withOsType(OperatingSystemTypes.WINDOWS)
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.FROM_IMAGE)
                    .withGalleryImageReference(new ImageDiskReference().withSharedGalleryImageId(
                        "/SharedGalleries/{sharedGalleryUniqueName}/Images/{imageName}/Versions/1.0.0"))),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_from_an_azure_compute_gallery_direct_shared_image.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscriptionId}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {
                    "createOption": "FromImage",
                    "galleryImageReference": {
                        "sharedGalleryImageId": "/SharedGalleries/{sharedGalleryUniqueName}/Images/{imageName}/Versions/1.0.0"
                    },
                },
                "osType": "Windows",
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryDirectSharedImage.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryDirectSharedImage.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskFromAnAzureComputeGalleryDirectSharedImage() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionFromImage),
				GalleryImageReference: &armcompute.ImageDiskReference{
					SharedGalleryImageID: to.Ptr("/SharedGalleries/{sharedGalleryUniqueName}/Images/{imageName}/Versions/1.0.0"),
				},
			},
			OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionFromImage),
	// 			GalleryImageReference: &armcompute.ImageDiskReference{
	// 				SharedGalleryImageID: to.Ptr("/SharedGalleries/{sharedGalleryUniqueName}/Images/{imageName}/Versions/1.0.0"),
	// 			},
	// 		},
	// 		HyperVGeneration: to.Ptr(armcompute.HyperVGenerationV1),
	// 		OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 		SupportedCapabilities: &armcompute.SupportedCapabilities{
	// 			AcceleratedNetwork: to.Ptr(true),
	// 		},
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryDirectSharedImage.json
 */
async function createAManagedDiskFromAnAzureComputeGalleryDirectSharedImage() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscriptionId}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: {
      createOption: "FromImage",
      galleryImageReference: {
        sharedGalleryImageId:
          "/SharedGalleries/{sharedGalleryUniqueName}/Images/{imageName}/Versions/1.0.0",
      },
    },
    location: "West US",
    osType: "Windows",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryDirectSharedImage.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscriptionId}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    OSType = SupportedOperatingSystemType.Windows,
    CreationData = new DiskCreationData(DiskCreateOption.FromImage)
    {
        GalleryImageReference = new ImageDiskReference
        {
            SharedGalleryImageId = "/SharedGalleries/{sharedGalleryUniqueName}/Images/{imageName}/Versions/1.0.0",
        },
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Succeeded",
    "osType": "Windows",
    "hyperVGeneration": "V1",
    "supportedCapabilities": {
      "acceleratedNetwork": true
    },
    "creationData": {
      "createOption": "FromImage",
      "galleryImageReference": {
        "sharedGalleryImageId": "/SharedGalleries/{sharedGalleryUniqueName}/Images/{imageName}/Versions/1.0.0"
      }
    }
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "osType": "Windows",
    "hyperVGeneration": "V1",
    "supportedCapabilities": {
      "acceleratedNetwork": true
    },
    "creationData": {
      "createOption": "FromImage",
      "galleryImageReference": {
        "sharedGalleryImageId": "/SharedGalleries/{sharedGalleryUniqueName}/Images/{imageName}/Versions/1.0.0"
      }
    },
    "provisioningState": "Updating"
  }
}
				 
				create a managed disk from an Azure Compute Gallery image.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "osType": "Windows",
    "creationData": {
      "createOption": "FromImage",
      "galleryImageReference": {
        "id": "/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Providers/Microsoft.Compute/Galleries/{galleryName}/Images/{imageName}/Versions/1.0.0"
      }
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.ImageDiskReference;
import com.azure.resourcemanager.compute.models.OperatingSystemTypes;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_FromAnAzureComputeGalleryImage.json
     */
    /**
     * Sample code: create a managed disk from an Azure Compute Gallery image.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void
        createAManagedDiskFromAnAzureComputeGalleryImage(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US").withOsType(OperatingSystemTypes.WINDOWS)
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.FROM_IMAGE)
                    .withGalleryImageReference(new ImageDiskReference().withId(
                        "/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Providers/Microsoft.Compute/Galleries/{galleryName}/Images/{imageName}/Versions/1.0.0"))),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_from_an_azure_compute_gallery_image.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscriptionId}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {
                    "createOption": "FromImage",
                    "galleryImageReference": {
                        "id": "/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Providers/Microsoft.Compute/Galleries/{galleryName}/Images/{imageName}/Versions/1.0.0"
                    },
                },
                "osType": "Windows",
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryImage.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryImage.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskFromAnAzureComputeGalleryImage() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionFromImage),
				GalleryImageReference: &armcompute.ImageDiskReference{
					ID: to.Ptr("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Providers/Microsoft.Compute/Galleries/{galleryName}/Images/{imageName}/Versions/1.0.0"),
				},
			},
			OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionFromImage),
	// 			GalleryImageReference: &armcompute.ImageDiskReference{
	// 				ID: to.Ptr("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Providers/Microsoft.Compute/Galleries/{galleryName}/Images/{imageName}/Versions/1.0.0"),
	// 			},
	// 		},
	// 		HyperVGeneration: to.Ptr(armcompute.HyperVGenerationV1),
	// 		OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 		SupportedCapabilities: &armcompute.SupportedCapabilities{
	// 			AcceleratedNetwork: to.Ptr(true),
	// 			SupportedSecurityOption: to.Ptr(armcompute.SupportedSecurityOptionTrustedLaunchSupported),
	// 		},
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryImage.json
 */
async function createAManagedDiskFromAnAzureComputeGalleryImage() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscriptionId}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: {
      createOption: "FromImage",
      galleryImageReference: {
        id: "/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Providers/Microsoft.Compute/Galleries/{galleryName}/Images/{imageName}/Versions/1.0.0",
      },
    },
    location: "West US",
    osType: "Windows",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnAzureComputeGalleryImage.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscriptionId}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    OSType = SupportedOperatingSystemType.Windows,
    CreationData = new DiskCreationData(DiskCreateOption.FromImage)
    {
        GalleryImageReference = new ImageDiskReference
        {
            Id = new ResourceIdentifier("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Providers/Microsoft.Compute/Galleries/{galleryName}/Images/{imageName}/Versions/1.0.0"),
        },
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Succeeded",
    "osType": "Windows",
    "hyperVGeneration": "V1",
    "supportedCapabilities": {
      "acceleratedNetwork": true,
      "supportedSecurityOption": "TrustedLaunchSupported"
    },
    "creationData": {
      "createOption": "FromImage",
      "galleryImageReference": {
        "id": "/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Providers/Microsoft.Compute/Galleries/{galleryName}/Images/{imageName}/Versions/1.0.0"
      }
    }
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "osType": "Windows",
    "hyperVGeneration": "V1",
    "supportedCapabilities": {
      "acceleratedNetwork": true,
      "supportedSecurityOption": "TrustedLaunchSupported"
    },
    "creationData": {
      "createOption": "FromImage",
      "galleryImageReference": {
        "id": "/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Providers/Microsoft.Compute/Galleries/{galleryName}/Images/{imageName}/Versions/1.0.0"
      }
    },
    "provisioningState": "Updating"
  }
}
				 
				create a managed disk from an existing managed disk in the same or different subscription.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk2?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "creationData": {
      "createOption": "Copy",
      "sourceResourceId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk1"
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_FromAnExistingManagedDisk.json
     */
    /**
     * Sample code: create a managed disk from an existing managed disk in the same or different subscription.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedDiskFromAnExistingManagedDiskInTheSameOrDifferentSubscription(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk2",
            new DiskInner().withLocation("West US")
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.COPY).withSourceResourceId(
                    "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk1")),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_from_an_existing_managed_disk.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk2",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {
                    "createOption": "Copy",
                    "sourceResourceId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk1",
                }
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnExistingManagedDisk.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnExistingManagedDisk.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskFromAnExistingManagedDiskInTheSameOrDifferentSubscription() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk2", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption:     to.Ptr(armcompute.DiskCreateOptionCopy),
				SourceResourceID: to.Ptr("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk1"),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk2"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionCopy),
	// 			SourceResourceID: to.Ptr("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk1"),
	// 		},
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnExistingManagedDisk.json
 */
async function createAManagedDiskFromAnExistingManagedDiskInTheSameOrDifferentSubscription() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk2";
  const disk = {
    creationData: {
      createOption: "Copy",
      sourceResourceId:
        "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk1",
    },
    location: "West US",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnExistingManagedDisk.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk2";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    CreationData = new DiskCreationData(DiskCreateOption.Copy)
    {
        SourceResourceId = new ResourceIdentifier("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk1"),
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Copy",
      "sourceResourceId": "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk1"
    },
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk2"
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Copy",
      "sourceResourceId": "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk1"
    },
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk2"
}
				 
				create a managed disk from elastic san volume snapshot.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "creationData": {
      "createOption": "CopyFromSanSnapshot",
      "elasticSanResourceId": "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ElasticSan/elasticSans/myElasticSan/volumegroups/myElasticSanVolumeGroup/snapshots/myElasticSanVolumeSnapshot"
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_FromAnElasticSanVolumeSnapshot.json
     */
    /**
     * Sample code: create a managed disk from elastic san volume snapshot.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void
        createAManagedDiskFromElasticSanVolumeSnapshot(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US").withCreationData(
                new CreationData().withCreateOption(DiskCreateOption.COPY_FROM_SAN_SNAPSHOT).withElasticSanResourceId(
                    "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ElasticSan/elasticSans/myElasticSan/volumegroups/myElasticSanVolumeGroup/snapshots/myElasticSanVolumeSnapshot")),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_from_an_elastic_san_volume_snapshot.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {
                    "createOption": "CopyFromSanSnapshot",
                    "elasticSanResourceId": "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ElasticSan/elasticSans/myElasticSan/volumegroups/myElasticSanVolumeGroup/snapshots/myElasticSanVolumeSnapshot",
                }
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnElasticSanVolumeSnapshot.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnElasticSanVolumeSnapshot.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskFromElasticSanVolumeSnapshot() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption:         to.Ptr(armcompute.DiskCreateOptionCopyFromSanSnapshot),
				ElasticSanResourceID: to.Ptr("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ElasticSan/elasticSans/myElasticSan/volumegroups/myElasticSanVolumeGroup/snapshots/myElasticSanVolumeSnapshot"),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionCopyFromSanSnapshot),
	// 			ElasticSanResourceID: to.Ptr("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ElasticSan/elasticSans/myElasticSan/volumegroups/myElasticSanVolumeGroup/snapshots/myElasticSanVolumeSnapshot"),
	// 		},
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnElasticSanVolumeSnapshot.json
 */
async function createAManagedDiskFromElasticSanVolumeSnapshot() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: {
      createOption: "CopyFromSanSnapshot",
      elasticSanResourceId:
        "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ElasticSan/elasticSans/myElasticSan/volumegroups/myElasticSanVolumeGroup/snapshots/myElasticSanVolumeSnapshot",
    },
    location: "West US",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromAnElasticSanVolumeSnapshot.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    CreationData = new DiskCreationData(DiskCreateOption.CopyFromSanSnapshot)
    {
        ElasticSanResourceId = new ResourceIdentifier("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ElasticSan/elasticSans/myElasticSan/volumegroups/myElasticSanVolumeGroup/snapshots/myElasticSanVolumeSnapshot"),
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "CopyFromSanSnapshot",
      "elasticSanResourceId": "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ElasticSan/elasticSans/myElasticSan/volumegroups/myElasticSanVolumeGroup/snapshots/myElasticSanVolumeSnapshot"
    },
    "provisioningState": "Succeeded"
  },
  "location": "West US",
  "name": "myDisk"
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "CopyFromSanSnapshot",
      "elasticSanResourceId": "subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ElasticSan/elasticSans/myElasticSan/volumegroups/myElasticSanVolumeGroup/snapshots/myElasticSanVolumeSnapshot"
    },
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk"
}
				 
				create a managed disk from ImportSecure create option
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "osType": "Windows",
    "securityProfile": {
      "securityType": "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey"
    },
    "creationData": {
      "createOption": "ImportSecure",
      "storageAccountId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
      "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
      "securityDataUri": "https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd"
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.DiskSecurityProfile;
import com.azure.resourcemanager.compute.models.DiskSecurityTypes;
import com.azure.resourcemanager.compute.models.OperatingSystemTypes;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_FromImportSecure.json
     */
    /**
     * Sample code: create a managed disk from ImportSecure create option.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void
        createAManagedDiskFromImportSecureCreateOption(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US").withOsType(OperatingSystemTypes.WINDOWS).withCreationData(
                new CreationData().withCreateOption(DiskCreateOption.IMPORT_SECURE).withStorageAccountId(
                    "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount")
                    .withSourceUri("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd")
                    .withSecurityDataUri("https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd"))
                .withSecurityProfile(new DiskSecurityProfile().withSecurityType(
                    DiskSecurityTypes.CONFIDENTIAL_VM_VMGUEST_STATE_ONLY_ENCRYPTED_WITH_PLATFORM_KEY)),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_from_import_secure.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {
                    "createOption": "ImportSecure",
                    "securityDataUri": "https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd",
                    "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
                    "storageAccountId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
                },
                "osType": "Windows",
                "securityProfile": {"securityType": "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey"},
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromImportSecure.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromImportSecure.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskFromImportSecureCreateOption() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption:     to.Ptr(armcompute.DiskCreateOptionImportSecure),
				SecurityDataURI:  to.Ptr("https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd"),
				SourceURI:        to.Ptr("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"),
				StorageAccountID: to.Ptr("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount"),
			},
			OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
			SecurityProfile: &armcompute.DiskSecurityProfile{
				SecurityType: to.Ptr(armcompute.DiskSecurityTypesConfidentialVMVmguestStateOnlyEncryptedWithPlatformKey),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionImportSecure),
	// 			SecurityDataURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd"),
	// 			SourceURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"),
	// 			StorageAccountID: to.Ptr("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount"),
	// 		},
	// 		OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 		SecurityProfile: &armcompute.DiskSecurityProfile{
	// 			SecurityType: to.Ptr(armcompute.DiskSecurityTypesConfidentialVMVmguestStateOnlyEncryptedWithPlatformKey),
	// 		},
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromImportSecure.json
 */
async function createAManagedDiskFromImportSecureCreateOption() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: {
      createOption: "ImportSecure",
      securityDataUri: "https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd",
      sourceUri: "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
      storageAccountId:
        "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
    },
    location: "West US",
    osType: "Windows",
    securityProfile: {
      securityType: "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey",
    },
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromImportSecure.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    OSType = SupportedOperatingSystemType.Windows,
    CreationData = new DiskCreationData(DiskCreateOption.ImportSecure)
    {
        StorageAccountId = new ResourceIdentifier("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount"),
        SourceUri = new Uri("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"),
        SecurityDataUri = new Uri("https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd"),
    },
    SecurityProfile = new DiskSecurityProfile
    {
        SecurityType = DiskSecurityType.ConfidentialVmGuestStateOnlyEncryptedWithPlatformKey,
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Succeeded",
    "osType": "Windows",
    "securityProfile": {
      "securityType": "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey"
    },
    "creationData": {
      "createOption": "ImportSecure",
      "storageAccountId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
      "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
      "securityDataUri": "https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd"
    }
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Updating",
    "osType": "Windows",
    "securityProfile": {
      "securityType": "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey"
    },
    "creationData": {
      "createOption": "ImportSecure",
      "storageAccountId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
      "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
      "securityDataUri": "https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd"
    }
  }
}
				 
				
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "osType": "Windows",
    "securityProfile": {
      "securityType": "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey"
    },
    "creationData": {
      "createOption": "ImportSecure",
      "storageAccountId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
      "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
      "securityDataUri": "https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd",
      "securityMetadataUri": "https://mystorageaccount.blob.core.windows.net/osimages/vmmd.vhd"
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.DiskSecurityProfile;
import com.azure.resourcemanager.compute.models.DiskSecurityTypes;
import com.azure.resourcemanager.compute.models.OperatingSystemTypes;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_FromImportSecure_WithVMMetadata.json
     */
    /**
     * Sample code: create a managed disk from ImportSecure create option with metadata URI for Confidential VM.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedDiskFromImportSecureCreateOptionWithMetadataURIForConfidentialVM(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US").withOsType(OperatingSystemTypes.WINDOWS).withCreationData(
                new CreationData().withCreateOption(DiskCreateOption.IMPORT_SECURE).withStorageAccountId(
                    "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount")
                    .withSourceUri("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd")
                    .withSecurityDataUri("https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd")
                    .withSecurityMetadataUri("https://mystorageaccount.blob.core.windows.net/osimages/vmmd.vhd"))
                .withSecurityProfile(new DiskSecurityProfile().withSecurityType(
                    DiskSecurityTypes.CONFIDENTIAL_VM_VMGUEST_STATE_ONLY_ENCRYPTED_WITH_PLATFORM_KEY)),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_from_import_secure_with_vm_metadata.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {
                    "createOption": "ImportSecure",
                    "securityDataUri": "https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd",
                    "securityMetadataUri": "https://mystorageaccount.blob.core.windows.net/osimages/vmmd.vhd",
                    "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
                    "storageAccountId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
                },
                "osType": "Windows",
                "securityProfile": {"securityType": "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey"},
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromImportSecure_WithVMMetadata.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromImportSecure_WithVMMetadata.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskFromImportSecureCreateOptionWithMetadataUriForConfidentialVm() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption:        to.Ptr(armcompute.DiskCreateOptionImportSecure),
				SecurityDataURI:     to.Ptr("https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd"),
				SecurityMetadataURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/osimages/vmmd.vhd"),
				SourceURI:           to.Ptr("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"),
				StorageAccountID:    to.Ptr("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount"),
			},
			OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
			SecurityProfile: &armcompute.DiskSecurityProfile{
				SecurityType: to.Ptr(armcompute.DiskSecurityTypesConfidentialVMVmguestStateOnlyEncryptedWithPlatformKey),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionImportSecure),
	// 			SecurityDataURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd"),
	// 			SecurityMetadataURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/osimages/vmmd.vhd"),
	// 			SourceURI: to.Ptr("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"),
	// 			StorageAccountID: to.Ptr("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount"),
	// 		},
	// 		OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 		SecurityProfile: &armcompute.DiskSecurityProfile{
	// 			SecurityType: to.Ptr(armcompute.DiskSecurityTypesConfidentialVMVmguestStateOnlyEncryptedWithPlatformKey),
	// 		},
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromImportSecure_WithVMMetadata.json
 */
async function createAManagedDiskFromImportSecureCreateOptionWithMetadataUriForConfidentialVM() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: {
      createOption: "ImportSecure",
      securityDataUri: "https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd",
      securityMetadataUri: "https://mystorageaccount.blob.core.windows.net/osimages/vmmd.vhd",
      sourceUri: "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
      storageAccountId:
        "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
    },
    location: "West US",
    osType: "Windows",
    securityProfile: {
      securityType: "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey",
    },
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromImportSecure_WithVMMetadata.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    OSType = SupportedOperatingSystemType.Windows,
    CreationData = new DiskCreationData(DiskCreateOption.ImportSecure)
    {
        StorageAccountId = new ResourceIdentifier("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount"),
        SourceUri = new Uri("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"),
        SecurityDataUri = new Uri("https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd"),
        SecurityMetadataUri = new Uri("https://mystorageaccount.blob.core.windows.net/osimages/vmmd.vhd"),
    },
    SecurityProfile = new DiskSecurityProfile
    {
        SecurityType = DiskSecurityType.ConfidentialVmGuestStateOnlyEncryptedWithPlatformKey,
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Updating",
    "osType": "Windows",
    "securityProfile": {
      "securityType": "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey"
    },
    "creationData": {
      "createOption": "ImportSecure",
      "storageAccountId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
      "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
      "securityDataUri": "https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd",
      "securityMetadataUri": "https://mystorageaccount.blob.core.windows.net/osimages/vmmd.vhd"
    }
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "West US",
  "properties": {
    "provisioningState": "Succeeded",
    "osType": "Windows",
    "securityProfile": {
      "securityType": "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey"
    },
    "creationData": {
      "createOption": "ImportSecure",
      "storageAccountId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount",
      "sourceUri": "https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd",
      "securityDataUri": "https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd",
      "securityMetadataUri": "https://mystorageaccount.blob.core.windows.net/osimages/vmmd.vhd"
    }
  }
}
				 
				create a managed disk from UploadPreparedSecure create option
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "osType": "Windows",
    "securityProfile": {
      "securityType": "TrustedLaunch"
    },
    "creationData": {
      "createOption": "UploadPreparedSecure",
      "uploadSizeBytes": 10737418752
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.DiskSecurityProfile;
import com.azure.resourcemanager.compute.models.DiskSecurityTypes;
import com.azure.resourcemanager.compute.models.OperatingSystemTypes;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_FromUploadPreparedSecure.json
     */
    /**
     * Sample code: create a managed disk from UploadPreparedSecure create option.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void
        createAManagedDiskFromUploadPreparedSecureCreateOption(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US").withOsType(OperatingSystemTypes.WINDOWS)
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.UPLOAD_PREPARED_SECURE)
                    .withUploadSizeBytes(10737418752L))
                .withSecurityProfile(new DiskSecurityProfile().withSecurityType(DiskSecurityTypes.TRUSTED_LAUNCH)),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_from_upload_prepared_secure.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {"createOption": "UploadPreparedSecure", "uploadSizeBytes": 10737418752},
                "osType": "Windows",
                "securityProfile": {"securityType": "TrustedLaunch"},
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromUploadPreparedSecure.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromUploadPreparedSecure.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskFromUploadPreparedSecureCreateOption() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption:    to.Ptr(armcompute.DiskCreateOptionUploadPreparedSecure),
				UploadSizeBytes: to.Ptr[int64](10737418752),
			},
			OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
			SecurityProfile: &armcompute.DiskSecurityProfile{
				SecurityType: to.Ptr(armcompute.DiskSecurityTypesTrustedLaunch),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionUploadPreparedSecure),
	// 			UploadSizeBytes: to.Ptr[int64](10737418752),
	// 		},
	// 		OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 		SecurityProfile: &armcompute.DiskSecurityProfile{
	// 			SecurityType: to.Ptr(armcompute.DiskSecurityTypesTrustedLaunch),
	// 		},
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromUploadPreparedSecure.json
 */
async function createAManagedDiskFromUploadPreparedSecureCreateOption() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: {
      createOption: "UploadPreparedSecure",
      uploadSizeBytes: 10737418752,
    },
    location: "West US",
    osType: "Windows",
    securityProfile: { securityType: "TrustedLaunch" },
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_FromUploadPreparedSecure.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    OSType = SupportedOperatingSystemType.Windows,
    CreationData = new DiskCreationData(DiskCreateOption.UploadPreparedSecure)
    {
        UploadSizeBytes = 10737418752L,
    },
    SecurityProfile = new DiskSecurityProfile
    {
        SecurityType = DiskSecurityType.TrustedLaunch,
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "osType": "Windows",
    "securityProfile": {
      "securityType": "TrustedLaunch"
    },
    "creationData": {
      "createOption": "UploadPreparedSecure",
      "uploadSizeBytes": 10737418752
    },
    "provisioningState": "Succeeded"
  },
  "location": "West US",
  "name": "myDisk"
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "osType": "Windows",
    "securityProfile": {
      "securityType": "TrustedLaunch"
    },
    "creationData": {
      "createOption": "UploadPreparedSecure",
      "uploadSizeBytes": 10737418752
    },
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk"
}
				 
				create a managed disk with availability policy.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 1024,
    "availabilityPolicy": {
      "actionOnDiskDelay": "AutomaticReattach"
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.AvailabilityPolicy;
import com.azure.resourcemanager.compute.models.AvailabilityPolicyDiskDelay;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_CreateOrUpdate_AvailabilityPolicy.json
     */
    /**
     * Sample code: create a managed disk with availability policy.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedDiskWithAvailabilityPolicy(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US")
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.EMPTY)).withDiskSizeGB(1024)
                .withAvailabilityPolicy(
                    new AvailabilityPolicy().withActionOnDiskDelay(AvailabilityPolicyDiskDelay.AUTOMATIC_REATTACH)),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_or_update_availability_policy.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "availabilityPolicy": {"actionOnDiskDelay": "AutomaticReattach"},
                "creationData": {"createOption": "Empty"},
                "diskSizeGB": 1024,
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_CreateOrUpdate_AvailabilityPolicy.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_CreateOrUpdate_AvailabilityPolicy.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskWithAvailabilityPolicy() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			AvailabilityPolicy: &armcompute.AvailabilityPolicy{
				ActionOnDiskDelay: to.Ptr(armcompute.AvailabilityPolicyDiskDelayAutomaticReattach),
			},
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
			},
			DiskSizeGB: to.Ptr[int32](1024),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		AvailabilityPolicy: &armcompute.AvailabilityPolicy{
	// 			ActionOnDiskDelay: to.Ptr(armcompute.AvailabilityPolicyDiskDelayAutomaticReattach),
	// 		},
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
	// 		},
	// 		DiskSizeGB: to.Ptr[int32](1024),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_CreateOrUpdate_AvailabilityPolicy.json
 */
async function createAManagedDiskWithAvailabilityPolicy() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    availabilityPolicy: { actionOnDiskDelay: "AutomaticReattach" },
    creationData: { createOption: "Empty" },
    diskSizeGB: 1024,
    location: "West US",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_CreateOrUpdate_AvailabilityPolicy.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    CreationData = new DiskCreationData(DiskCreateOption.Empty),
    DiskSizeGB = 1024,
    AvailabilityActionOnDiskDelay = AvailabilityPolicyDiskDelay.AutomaticReattach,
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							Location: https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
								
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 1024,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk"
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 1024,
    "availabilityPolicy": {
      "actionOnDiskDelay": "AutomaticReattach"
    },
    "provisioningState": "Succeeded"
  },
  "location": "West US",
  "name": "myDisk"
}
				 
				create a managed disk with dataAccessAuthMode
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "dataAccessAuthMode": "AzureActiveDirectory"
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DataAccessAuthMode;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_WithDataAccessAuthMode.json
     */
    /**
     * Sample code: create a managed disk with dataAccessAuthMode.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedDiskWithDataAccessAuthMode(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US")
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.EMPTY)).withDiskSizeGB(200)
                .withDataAccessAuthMode(DataAccessAuthMode.AZURE_ACTIVE_DIRECTORY),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_with_data_access_auth_mode.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {"createOption": "Empty"},
                "dataAccessAuthMode": "AzureActiveDirectory",
                "diskSizeGB": 200,
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithDataAccessAuthMode.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithDataAccessAuthMode.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskWithDataAccessAuthMode() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
			},
			DataAccessAuthMode: to.Ptr(armcompute.DataAccessAuthModeAzureActiveDirectory),
			DiskSizeGB:         to.Ptr[int32](200),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
	// 		},
	// 		DataAccessAuthMode: to.Ptr(armcompute.DataAccessAuthModeAzureActiveDirectory),
	// 		DiskSizeGB: to.Ptr[int32](200),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithDataAccessAuthMode.json
 */
async function createAManagedDiskWithDataAccessAuthMode() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: { createOption: "Empty" },
    dataAccessAuthMode: "AzureActiveDirectory",
    diskSizeGB: 200,
    location: "West US",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithDataAccessAuthMode.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    CreationData = new DiskCreationData(DiskCreateOption.Empty),
    DiskSizeGB = 200,
    DataAccessAuthMode = DataAccessAuthMode.AzureActiveDirectory,
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Succeeded",
    "dataAccessAuthMode": "AzureActiveDirectory"
  },
  "location": "West US",
  "name": "myDisk"
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk"
}
				 
				create a managed disk with optimizedForFrequentAttach.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "optimizedForFrequentAttach": true
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_WithOptimizedForFrequentAttach.json
     */
    /**
     * Sample code: create a managed disk with optimizedForFrequentAttach.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void
        createAManagedDiskWithOptimizedForFrequentAttach(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US")
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.EMPTY)).withDiskSizeGB(200)
                .withOptimizedForFrequentAttach(true),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_with_optimized_for_frequent_attach.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {"createOption": "Empty"},
                "diskSizeGB": 200,
                "optimizedForFrequentAttach": True,
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithOptimizedForFrequentAttach.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithOptimizedForFrequentAttach.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskWithOptimizedForFrequentAttach() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
			},
			DiskSizeGB:                 to.Ptr[int32](200),
			OptimizedForFrequentAttach: to.Ptr(true),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
	// 		},
	// 		DiskSizeGB: to.Ptr[int32](200),
	// 		OptimizedForFrequentAttach: to.Ptr(true),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithOptimizedForFrequentAttach.json
 */
async function createAManagedDiskWithOptimizedForFrequentAttach() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: { createOption: "Empty" },
    diskSizeGB: 200,
    location: "West US",
    optimizedForFrequentAttach: true,
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithOptimizedForFrequentAttach.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    CreationData = new DiskCreationData(DiskCreateOption.Empty),
    DiskSizeGB = 200,
    IsOptimizedForFrequentAttach = true,
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Succeeded",
    "optimizedForFrequentAttach": true
  },
  "location": "West US",
  "name": "myDisk"
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating",
    "optimizedForFrequentAttach": true
  },
  "location": "West US",
  "name": "myDisk"
}
				 
				
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "creationData": {
      "createOption": "Upload",
      "performancePlus": true
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_PerformancePlus.json
     */
    /**
     * Sample code: create a managed disk with performancePlus.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedDiskWithPerformancePlus(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US").withCreationData(
                new CreationData().withCreateOption(DiskCreateOption.UPLOAD).withPerformancePlus(true)),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_performance_plus.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {"creationData": {"createOption": "Upload", "performancePlus": True}},
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_PerformancePlus.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_PerformancePlus.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskWithPerformancePlus() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption:    to.Ptr(armcompute.DiskCreateOptionUpload),
				PerformancePlus: to.Ptr(true),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionUpload),
	// 			PerformancePlus: to.Ptr(true),
	// 		},
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_PerformancePlus.json
 */
async function createAManagedDiskWithPerformancePlus() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: { createOption: "Upload", performancePlus: true },
    location: "West US",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_PerformancePlus.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    CreationData = new DiskCreationData(DiskCreateOption.Upload)
    {
        IsPerformancePlusEnabled = true,
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Upload",
      "performancePlus": true
    },
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk"
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Upload",
      "performancePlus": true
    },
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk"
}
				 
				create a managed disk with premium v2 account type.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myPremiumV2Disk?api-version=2025-01-02
{
  "location": "West US",
  "sku": {
    "name": "PremiumV2_LRS"
  },
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "diskIOPSReadWrite": 125,
    "diskMBpsReadWrite": 3000
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.DiskSku;
import com.azure.resourcemanager.compute.models.DiskStorageAccountTypes;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_WithPremiumV2_LRSAccountType.json
     */
    /**
     * Sample code: create a managed disk with premium v2 account type.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void
        createAManagedDiskWithPremiumV2AccountType(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup",
            "myPremiumV2Disk",
            new DiskInner().withLocation("West US")
                .withSku(new DiskSku().withName(DiskStorageAccountTypes.PREMIUM_V2_LRS))
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.EMPTY)).withDiskSizeGB(200)
                .withDiskIopsReadWrite(125L).withDiskMBpsReadWrite(3000L),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_with_premium_v2_lrsaccount_type.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myPremiumV2Disk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {"createOption": "Empty"},
                "diskIOPSReadWrite": 125,
                "diskMBpsReadWrite": 3000,
                "diskSizeGB": 200,
            },
            "sku": {"name": "PremiumV2_LRS"},
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithPremiumV2_LRSAccountType.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithPremiumV2_LRSAccountType.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskWithPremiumV2AccountType() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myPremiumV2Disk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
			},
			DiskIOPSReadWrite: to.Ptr[int64](125),
			DiskMBpsReadWrite: to.Ptr[int64](3000),
			DiskSizeGB:        to.Ptr[int32](200),
		},
		SKU: &armcompute.DiskSKU{
			Name: to.Ptr(armcompute.DiskStorageAccountTypesPremiumV2LRS),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myPremiumV2Disk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
	// 		},
	// 		DiskSizeGB: to.Ptr[int32](200),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// 	SKU: &armcompute.DiskSKU{
	// 		Name: to.Ptr(armcompute.DiskStorageAccountTypesPremiumV2LRS),
	// 		Tier: to.Ptr("Premium"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithPremiumV2_LRSAccountType.json
 */
async function createAManagedDiskWithPremiumV2AccountType() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myPremiumV2Disk";
  const disk = {
    creationData: { createOption: "Empty" },
    diskIopsReadWrite: 125,
    diskMBpsReadWrite: 3000,
    diskSizeGB: 200,
    location: "West US",
    sku: { name: "PremiumV2_LRS" },
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithPremiumV2_LRSAccountType.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myPremiumV2Disk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    Sku = new DiskSku
    {
        Name = DiskStorageAccountType.PremiumV2Lrs,
    },
    CreationData = new DiskCreationData(DiskCreateOption.Empty),
    DiskSizeGB = 200,
    DiskIopsReadWrite = 125L,
    DiskMBpsReadWrite = 3000L,
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myPremiumV2Disk",
  "sku": {
    "name": "PremiumV2_LRS",
    "tier": "Premium"
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myPremiumV2Disk",
  "sku": {
    "name": "PremiumV2_LRS",
    "tier": "Premium"
  }
}
				 
				create a managed disk with security profile
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "North Central US",
  "properties": {
    "osType": "Windows",
    "securityProfile": {
      "securityType": "TrustedLaunch"
    },
    "creationData": {
      "createOption": "FromImage",
      "imageReference": {
        "id": "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/uswest/Publishers/Microsoft/ArtifactTypes/VMImage/Offers/{offer}"
      }
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.DiskSecurityProfile;
import com.azure.resourcemanager.compute.models.DiskSecurityTypes;
import com.azure.resourcemanager.compute.models.ImageDiskReference;
import com.azure.resourcemanager.compute.models.OperatingSystemTypes;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_WithSecurityProfile.json
     */
    /**
     * Sample code: create a managed disk with security profile.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedDiskWithSecurityProfile(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("North Central US").withOsType(OperatingSystemTypes.WINDOWS)
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.FROM_IMAGE)
                    .withImageReference(new ImageDiskReference().withId(
                        "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/uswest/Publishers/Microsoft/ArtifactTypes/VMImage/Offers/{offer}")))
                .withSecurityProfile(new DiskSecurityProfile().withSecurityType(DiskSecurityTypes.TRUSTED_LAUNCH)),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_with_security_profile.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "North Central US",
            "properties": {
                "creationData": {
                    "createOption": "FromImage",
                    "imageReference": {
                        "id": "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/uswest/Publishers/Microsoft/ArtifactTypes/VMImage/Offers/{offer}"
                    },
                },
                "osType": "Windows",
                "securityProfile": {"securityType": "TrustedLaunch"},
            },
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithSecurityProfile.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithSecurityProfile.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskWithSecurityProfile() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("North Central US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionFromImage),
				ImageReference: &armcompute.ImageDiskReference{
					ID: to.Ptr("/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/uswest/Publishers/Microsoft/ArtifactTypes/VMImage/Offers/{offer}"),
				},
			},
			OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
			SecurityProfile: &armcompute.DiskSecurityProfile{
				SecurityType: to.Ptr(armcompute.DiskSecurityTypesTrustedLaunch),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("North Central US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionFromImage),
	// 			ImageReference: &armcompute.ImageDiskReference{
	// 				ID: to.Ptr("/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/uswest/Publishers/Microsoft/ArtifactTypes/VMImage/Offers/{offer}"),
	// 			},
	// 		},
	// 		OSType: to.Ptr(armcompute.OperatingSystemTypesWindows),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 		SecurityProfile: &armcompute.DiskSecurityProfile{
	// 			SecurityType: to.Ptr(armcompute.DiskSecurityTypesTrustedLaunch),
	// 		},
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithSecurityProfile.json
 */
async function createAManagedDiskWithSecurityProfile() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: {
      createOption: "FromImage",
      imageReference: {
        id: "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/uswest/Publishers/Microsoft/ArtifactTypes/VMImage/Offers/{offer}",
      },
    },
    location: "North Central US",
    osType: "Windows",
    securityProfile: { securityType: "TrustedLaunch" },
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithSecurityProfile.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("North Central US"))
{
    OSType = SupportedOperatingSystemType.Windows,
    CreationData = new DiskCreationData(DiskCreateOption.FromImage)
    {
        ImageReference = new ImageDiskReference
        {
            Id = new ResourceIdentifier("/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/uswest/Publishers/Microsoft/ArtifactTypes/VMImage/Offers/{offer}"),
        },
    },
    SecurityProfile = new DiskSecurityProfile
    {
        SecurityType = DiskSecurityType.TrustedLaunch,
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "North Central US",
  "properties": {
    "provisioningState": "Succeeded",
    "osType": "Windows",
    "securityProfile": {
      "securityType": "TrustedLaunch"
    },
    "creationData": {
      "createOption": "FromImage",
      "imageReference": {
        "id": "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/uswest/Publishers/Microsoft/ArtifactTypes/VMImage/Offers/{offer}"
      }
    }
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "name": "myDisk",
  "location": "North Central US",
  "properties": {
    "provisioningState": "Updating",
    "osType": "Windows",
    "securityProfile": {
      "securityType": "TrustedLaunch"
    },
    "creationData": {
      "createOption": "FromImage",
      "imageReference": {
        "id": "/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/uswest/Publishers/Microsoft/ArtifactTypes/VMImage/Offers/{offer}"
      }
    }
  }
}
				 
				create a managed disk with ssd zrs account type.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "sku": {
    "name": "Premium_ZRS"
  },
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.DiskSku;
import com.azure.resourcemanager.compute.models.DiskStorageAccountTypes;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_WithSSDZRSAccountType.json
     */
    /**
     * Sample code: create a managed disk with ssd zrs account type.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedDiskWithSsdZrsAccountType(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US").withSku(new DiskSku().withName(DiskStorageAccountTypes.PREMIUM_ZRS))
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.EMPTY)).withDiskSizeGB(200),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_with_ssdzrs_account_type.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {"creationData": {"createOption": "Empty"}, "diskSizeGB": 200},
            "sku": {"name": "Premium_ZRS"},
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithSSDZRSAccountType.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithSSDZRSAccountType.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskWithSsdZrsAccountType() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
			},
			DiskSizeGB: to.Ptr[int32](200),
		},
		SKU: &armcompute.DiskSKU{
			Name: to.Ptr(armcompute.DiskStorageAccountTypesPremiumZRS),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
	// 		},
	// 		DiskSizeGB: to.Ptr[int32](200),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// 	SKU: &armcompute.DiskSKU{
	// 		Name: to.Ptr(armcompute.DiskStorageAccountTypesPremiumZRS),
	// 		Tier: to.Ptr("Premium"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithSSDZRSAccountType.json
 */
async function createAManagedDiskWithSsdZrsAccountType() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: { createOption: "Empty" },
    diskSizeGB: 200,
    location: "West US",
    sku: { name: "Premium_ZRS" },
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithSSDZRSAccountType.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    Sku = new DiskSku
    {
        Name = DiskStorageAccountType.PremiumZrs,
    },
    CreationData = new DiskCreationData(DiskCreateOption.Empty),
    DiskSizeGB = 200,
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk",
  "sku": {
    "name": "Premium_ZRS",
    "tier": "Premium"
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk",
  "sku": {
    "name": "Premium_ZRS",
    "tier": "Premium"
  }
}
				 
				create a managed disk with ultra account type with readOnly property set.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myUltraReadOnlyDisk?api-version=2025-01-02
{
  "location": "West US",
  "sku": {
    "name": "UltraSSD_LRS"
  },
  "properties": {
    "creationData": {
      "createOption": "Empty",
      "logicalSectorSize": 4096
    },
    "diskSizeGB": 200,
    "diskIOPSReadWrite": 125,
    "diskMBpsReadWrite": 3000,
    "encryption": {
      "type": "EncryptionAtRestWithPlatformKey"
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.DiskSku;
import com.azure.resourcemanager.compute.models.DiskStorageAccountTypes;
import com.azure.resourcemanager.compute.models.Encryption;
import com.azure.resourcemanager.compute.models.EncryptionType;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_WithUltraSSD_ReadOnly.json
     */
    /**
     * Sample code: create a managed disk with ultra account type with readOnly property set.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedDiskWithUltraAccountTypeWithReadOnlyPropertySet(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup",
            "myUltraReadOnlyDisk",
            new DiskInner().withLocation("West US")
                .withSku(new DiskSku().withName(DiskStorageAccountTypes.ULTRA_SSD_LRS))
                .withCreationData(
                    new CreationData().withCreateOption(DiskCreateOption.EMPTY).withLogicalSectorSize(4096))
                .withDiskSizeGB(200).withDiskIopsReadWrite(125L).withDiskMBpsReadWrite(3000L)
                .withEncryption(new Encryption().withType(EncryptionType.ENCRYPTION_AT_REST_WITH_PLATFORM_KEY)),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_with_ultra_ssd_read_only.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myUltraReadOnlyDisk",
        disk={
            "location": "West US",
            "properties": {
                "creationData": {"createOption": "Empty", "logicalSectorSize": 4096},
                "diskIOPSReadWrite": 125,
                "diskMBpsReadWrite": 3000,
                "diskSizeGB": 200,
                "encryption": {"type": "EncryptionAtRestWithPlatformKey"},
            },
            "sku": {"name": "UltraSSD_LRS"},
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithUltraSSD_ReadOnly.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithUltraSSD_ReadOnly.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedDiskWithUltraAccountTypeWithReadOnlyPropertySet() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myUltraReadOnlyDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption:      to.Ptr(armcompute.DiskCreateOptionEmpty),
				LogicalSectorSize: to.Ptr[int32](4096),
			},
			DiskIOPSReadWrite: to.Ptr[int64](125),
			DiskMBpsReadWrite: to.Ptr[int64](3000),
			DiskSizeGB:        to.Ptr[int32](200),
			Encryption: &armcompute.Encryption{
				Type: to.Ptr(armcompute.EncryptionTypeEncryptionAtRestWithPlatformKey),
			},
		},
		SKU: &armcompute.DiskSKU{
			Name: to.Ptr(armcompute.DiskStorageAccountTypesUltraSSDLRS),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myUltraReadOnlyDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
	// 		},
	// 		DiskSizeGB: to.Ptr[int32](200),
	// 		Encryption: &armcompute.Encryption{
	// 			Type: to.Ptr(armcompute.EncryptionTypeEncryptionAtRestWithPlatformKey),
	// 		},
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// 	SKU: &armcompute.DiskSKU{
	// 		Name: to.Ptr(armcompute.DiskStorageAccountTypesUltraSSDLRS),
	// 		Tier: to.Ptr("Ultra"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithUltraSSD_ReadOnly.json
 */
async function createAManagedDiskWithUltraAccountTypeWithReadOnlyPropertySet() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myUltraReadOnlyDisk";
  const disk = {
    creationData: { createOption: "Empty", logicalSectorSize: 4096 },
    diskIopsReadWrite: 125,
    diskMBpsReadWrite: 3000,
    diskSizeGB: 200,
    encryption: { type: "EncryptionAtRestWithPlatformKey" },
    location: "West US",
    sku: { name: "UltraSSD_LRS" },
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithUltraSSD_ReadOnly.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myUltraReadOnlyDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    Sku = new DiskSku
    {
        Name = DiskStorageAccountType.UltraSsdLrs,
    },
    CreationData = new DiskCreationData(DiskCreateOption.Empty)
    {
        LogicalSectorSize = 4096,
    },
    DiskSizeGB = 200,
    DiskIopsReadWrite = 125L,
    DiskMBpsReadWrite = 3000L,
    Encryption = new DiskEncryption
    {
        EncryptionType = ComputeEncryptionType.EncryptionAtRestWithPlatformKey,
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating",
    "encryption": {
      "type": "EncryptionAtRestWithPlatformKey"
    }
  },
  "location": "West US",
  "name": "myUltraReadOnlyDisk",
  "sku": {
    "name": "UltraSSD_LRS",
    "tier": "Ultra"
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myUltraReadOnlyDisk",
  "sku": {
    "name": "UltraSSD_LRS",
    "tier": "Ultra"
  }
}
				 
				create a managed upload disk.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "creationData": {
      "createOption": "Upload",
      "uploadSizeBytes": 10737418752
    }
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_UploadDisk.json
     */
    /**
     * Sample code: create a managed upload disk.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAManagedUploadDisk(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US").withCreationData(
                new CreationData().withCreateOption(DiskCreateOption.UPLOAD).withUploadSizeBytes(10737418752L)),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_upload_disk.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {"creationData": {"createOption": "Upload", "uploadSizeBytes": 10737418752}},
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_UploadDisk.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_UploadDisk.json
func ExampleDisksClient_BeginCreateOrUpdate_createAManagedUploadDisk() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption:    to.Ptr(armcompute.DiskCreateOptionUpload),
				UploadSizeBytes: to.Ptr[int64](10737418752),
			},
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionUpload),
	// 			UploadSizeBytes: to.Ptr[int64](10737418752),
	// 		},
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_UploadDisk.json
 */
async function createAManagedUploadDisk() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: { createOption: "Upload", uploadSizeBytes: 10737418752 },
    location: "West US",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_UploadDisk.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    CreationData = new DiskCreationData(DiskCreateOption.Upload)
    {
        UploadSizeBytes = 10737418752L,
    },
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Upload",
      "uploadSizeBytes": 10737418752
    },
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk"
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Upload",
      "uploadSizeBytes": 10737418752
    },
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk"
}
				 
				create an empty managed disk in extended location.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "extendedLocation": {
    "type": "EdgeZone",
    "name": "{edge-zone-id}"
  },
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.ExtendedLocation;
import com.azure.resourcemanager.compute.models.ExtendedLocationTypes;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_InExtendedLocation.json
     */
    /**
     * Sample code: create an empty managed disk in extended location.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void
        createAnEmptyManagedDiskInExtendedLocation(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US")
                .withExtendedLocation(
                    new ExtendedLocation().withName("{edge-zone-id}").withType(ExtendedLocationTypes.EDGE_ZONE))
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.EMPTY)).withDiskSizeGB(200),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_in_extended_location.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "extendedLocation": {"name": "{edge-zone-id}", "type": "EdgeZone"},
            "location": "West US",
            "properties": {"creationData": {"createOption": "Empty"}, "diskSizeGB": 200},
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_InExtendedLocation.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_InExtendedLocation.json
func ExampleDisksClient_BeginCreateOrUpdate_createAnEmptyManagedDiskInExtendedLocation() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		ExtendedLocation: &armcompute.ExtendedLocation{
			Name: to.Ptr("{edge-zone-id}"),
			Type: to.Ptr(armcompute.ExtendedLocationTypesEdgeZone),
		},
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
			},
			DiskSizeGB: to.Ptr[int32](200),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	ExtendedLocation: &armcompute.ExtendedLocation{
	// 		Name: to.Ptr("{edge-zone-id}"),
	// 		Type: to.Ptr(armcompute.ExtendedLocationTypesEdgeZone),
	// 	},
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
	// 		},
	// 		DiskSizeGB: to.Ptr[int32](200),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_InExtendedLocation.json
 */
async function createAnEmptyManagedDiskInExtendedLocation() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: { createOption: "Empty" },
    diskSizeGB: 200,
    extendedLocation: { name: "{edge-zone-id}", type: "EdgeZone" },
    location: "West US",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_InExtendedLocation.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    ExtendedLocation = new ExtendedLocation
    {
        Name = "{edge-zone-id}",
    },
    CreationData = new DiskCreationData(DiskCreateOption.Empty),
    DiskSizeGB = 200,
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk",
  "extendedLocation": {
    "type": "EdgeZone",
    "name": "{edge-zone-id}"
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk",
  "extendedLocation": {
    "type": "EdgeZone",
    "name": "{edge-zone-id}"
  }
}
				 
				create an empty managed disk.
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_Empty.json
     */
    /**
     * Sample code: create an empty managed disk.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void createAnEmptyManagedDisk(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US")
                .withCreationData(new CreationData().withCreateOption(DiskCreateOption.EMPTY)).withDiskSizeGB(200),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_empty.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={"location": "West US", "properties": {"creationData": {"createOption": "Empty"}, "diskSizeGB": 200}},
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_Empty.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_Empty.json
func ExampleDisksClient_BeginCreateOrUpdate_createAnEmptyManagedDisk() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
			},
			DiskSizeGB: to.Ptr[int32](200),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
	// 		},
	// 		DiskSizeGB: to.Ptr[int32](200),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_Empty.json
 */
async function createAnEmptyManagedDisk() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: { createOption: "Empty" },
    diskSizeGB: 200,
    location: "West US",
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_Empty.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    CreationData = new DiskCreationData(DiskCreateOption.Empty),
    DiskSizeGB = 200,
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk"
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk"
}
				 
				create an ultra managed disk with logicalSectorSize 512E
			
				Exempelbegäran
						
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk?api-version=2025-01-02
{
  "location": "West US",
  "sku": {
    "name": "UltraSSD_LRS"
  },
  "properties": {
    "creationData": {
      "createOption": "Empty",
      "logicalSectorSize": 512
    },
    "diskSizeGB": 200
  }
}
import com.azure.resourcemanager.compute.fluent.models.DiskInner;
import com.azure.resourcemanager.compute.models.CreationData;
import com.azure.resourcemanager.compute.models.DiskCreateOption;
import com.azure.resourcemanager.compute.models.DiskSku;
import com.azure.resourcemanager.compute.models.DiskStorageAccountTypes;
/**
 * Samples for Disks CreateOrUpdate.
 */
public final class Main {
    /*
     * x-ms-original-file:
     * specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/
     * Disk_Create_WithLogicalSectorSize.json
     */
    /**
     * Sample code: create an ultra managed disk with logicalSectorSize 512E.
     * 
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void
        createAnUltraManagedDiskWithLogicalSectorSize512E(com.azure.resourcemanager.AzureResourceManager azure) {
        azure.virtualMachines().manager().serviceClient().getDisks().createOrUpdate("myResourceGroup", "myDisk",
            new DiskInner().withLocation("West US")
                .withSku(new DiskSku().withName(DiskStorageAccountTypes.ULTRA_SSD_LRS))
                .withCreationData(
                    new CreationData().withCreateOption(DiskCreateOption.EMPTY).withLogicalSectorSize(512))
                .withDiskSizeGB(200),
            com.azure.core.util.Context.NONE);
    }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
    pip install azure-identity
    pip install azure-mgmt-compute
# USAGE
    python disk_create_with_logical_sector_size.py
    Before run the sample, please set the values of the client ID, tenant ID and client secret
    of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
    AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
    https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
    client = ComputeManagementClient(
        credential=DefaultAzureCredential(),
        subscription_id="{subscription-id}",
    )
    response = client.disks.begin_create_or_update(
        resource_group_name="myResourceGroup",
        disk_name="myDisk",
        disk={
            "location": "West US",
            "properties": {"creationData": {"createOption": "Empty", "logicalSectorSize": 512}, "diskSizeGB": 200},
            "sku": {"name": "UltraSSD_LRS"},
        },
    ).result()
    print(response)
# x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithLogicalSectorSize.json
if __name__ == "__main__":
    main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
	"context"
	"log"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v7"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/fb90eb1bec64c6e8ad3e288a64c84cc18742a394/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithLogicalSectorSize.json
func ExampleDisksClient_BeginCreateOrUpdate_createAnUltraManagedDiskWithLogicalSectorSize512E() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armcompute.NewClientFactory("<subscription-id>", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	poller, err := clientFactory.NewDisksClient().BeginCreateOrUpdate(ctx, "myResourceGroup", "myDisk", armcompute.Disk{
		Location: to.Ptr("West US"),
		Properties: &armcompute.DiskProperties{
			CreationData: &armcompute.CreationData{
				CreateOption:      to.Ptr(armcompute.DiskCreateOptionEmpty),
				LogicalSectorSize: to.Ptr[int32](512),
			},
			DiskSizeGB: to.Ptr[int32](200),
		},
		SKU: &armcompute.DiskSKU{
			Name: to.Ptr(armcompute.DiskStorageAccountTypesUltraSSDLRS),
		},
	}, nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	res, err := poller.PollUntilDone(ctx, nil)
	if err != nil {
		log.Fatalf("failed to pull the result: %v", err)
	}
	// You could use response here. We use blank identifier for just demo purposes.
	_ = res
	// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
	// res.Disk = armcompute.Disk{
	// 	Name: to.Ptr("myDisk"),
	// 	ID: to.Ptr("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk"),
	// 	Location: to.Ptr("West US"),
	// 	Properties: &armcompute.DiskProperties{
	// 		CreationData: &armcompute.CreationData{
	// 			CreateOption: to.Ptr(armcompute.DiskCreateOptionEmpty),
	// 			LogicalSectorSize: to.Ptr[int32](512),
	// 		},
	// 		DiskSizeGB: to.Ptr[int32](200),
	// 		ProvisioningState: to.Ptr("Succeeded"),
	// 	},
	// 	SKU: &armcompute.DiskSKU{
	// 		Name: to.Ptr(armcompute.DiskStorageAccountTypesUltraSSDLRS),
	// 		Tier: to.Ptr("Ultra"),
	// 	},
	// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
require("dotenv/config");
/**
 * This sample demonstrates how to Creates or updates a disk.
 *
 * @summary Creates or updates a disk.
 * x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithLogicalSectorSize.json
 */
async function createAnUltraManagedDiskWithLogicalSectorSize512E() {
  const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
  const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
  const diskName = "myDisk";
  const disk = {
    creationData: { createOption: "Empty", logicalSectorSize: 512 },
    diskSizeGB: 200,
    location: "West US",
    sku: { name: "UltraSSD_LRS" },
  };
  const credential = new DefaultAzureCredential();
  const client = new ComputeManagementClient(credential, subscriptionId);
  const result = await client.disks.beginCreateOrUpdateAndWait(resourceGroupName, diskName, disk);
  console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2025-01-02/examples/diskExamples/Disk_Create_WithLogicalSectorSize.json
// this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://free.blessedness.top/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ManagedDiskResource
ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks();
// invoke the operation
string diskName = "myDisk";
ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US"))
{
    Sku = new DiskSku
    {
        Name = DiskStorageAccountType.UltraSsdLrs,
    },
    CreationData = new DiskCreationData(DiskCreateOption.Empty)
    {
        LogicalSectorSize = 512,
    },
    DiskSizeGB = 200,
};
ArmOperation<ManagedDiskResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskName, data);
ManagedDiskResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDiskData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
 
			 
				
					Exempelsvar
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty",
      "logicalSectorSize": 512
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk",
  "sku": {
    "name": "UltraSSD_LRS",
    "tier": "Ultra"
  }
}
						
							{
  "id": "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk",
  "properties": {
    "creationData": {
      "createOption": "Empty",
      "logicalSectorSize": 512
    },
    "diskSizeGB": 200,
    "provisioningState": "Updating"
  },
  "location": "West US",
  "name": "myDisk",
  "sku": {
    "name": "UltraSSD_LRS",
    "tier": "Ultra"
  }
}
				 
		Definitioner
			
			ApiError
			Objekt
			API-fel.
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		code
	 | 
		
			 
					string
			 
	
		 | 
	
		 Felkoden. 
	 | 
	| 
		details
	 | 
		
			 
					ApiErrorBase[]
			 
	
		 | 
	
		 Information om API-fel 
	 | 
	| 
		innererror
	 | 
		
			 
					InnerError
			 
	
		 | 
	
		 Det inre API-felet 
	 | 
	| 
		message
	 | 
		
			 
					string
			 
	
		 | 
	
		 Felmeddelandet. 
	 | 
	| 
		target
	 | 
		
			 
					string
			 
	
		 | 
	
		 Målet för det specifika felet. 
	 | 
				
			ApiErrorBase
			Objekt
			bas för API-fel.
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		code
	 | 
		
			 
					string
			 
	
		 | 
	
		 Felkoden. 
	 | 
	| 
		message
	 | 
		
			 
					string
			 
	
		 | 
	
		 Felmeddelandet. 
	 | 
	| 
		target
	 | 
		
			 
					string
			 
	
		 | 
	
		 Målet för det specifika felet. 
	 | 
				
			Architecture
			Uppräkning
			CPU-arkitektur som stöds av en OS-disk.
				
					
							| Värde | 
						Description | 
					
	| 
		x64
	 | 
	
		
	 | 
	| 
		Arm64
	 | 
	
		
	 | 
				
			AvailabilityPolicy
			Objekt
			Om det uppstår ett tillgänglighets- eller anslutningsproblem med datadisken anger du beteendet för den virtuella datorn
				
			AvailabilityPolicyDiskDelay
			Uppräkning
			Avgör hur diskar med långsam I/O ska hanteras.
				
					
							| Värde | 
						Description | 
					
	| 
		None
	 | 
	
		 Standardvärdet är beteende utan att någon av-princip har angetts, vilket är omstart av den virtuella datorn vid långsam disk-I/O. 
	 | 
	| 
		AutomaticReattach
	 | 
	
		 Vid ett disk-I/O-fel eller långsamt svar kan du prova att koppla från och sedan ansluta disken igen. 
	 | 
				
			CloudError
			Objekt
			Ett felsvar från beräkningstjänsten.
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		error
	 | 
		
			 
					ApiError
			 
	
		 | 
	
		 API-fel. 
	 | 
				
			createdByType
			Uppräkning
			Den typ av identitet som skapade resursen.
				
					
							| Värde | 
						Description | 
					
	| 
		User
	 | 
	
		
	 | 
	| 
		Application
	 | 
	
		
	 | 
	| 
		ManagedIdentity
	 | 
	
		
	 | 
	| 
		Key
	 | 
	
		
	 | 
				
			CreationData
			Objekt
			Data som används när du skapar en disk.
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		createOption
	 | 
		
			 
					DiskCreateOption
			 
	
		 | 
	
		 Detta räknar upp möjliga källor för att skapa en disk. 
	 | 
	| 
		elasticSanResourceId
	 | 
		
			 
					string
			 
	
		 | 
	
		 Krävs om createOption är CopyFromSanSnapshot. Det här är ARM-ID:t för ögonblicksbilden av den elastiska volymen för källan. 
	 | 
	| 
		galleryImageReference
	 | 
		
			 
					ImageDiskReference
			 
	
		 | 
	
		 Krävs om du skapar från en galleribild. Id/sharedGalleryImageId/communityGalleryImageId för ImageDiskReference är ARM-ID:t för den delade galäravbildningsversionen som du vill skapa en disk från. 
	 | 
	| 
		imageReference
	 | 
		
			 
					ImageDiskReference
			 
	
		 | 
	
		 Information om diskkälla för PIR- eller användarbilder. 
	 | 
	| 
		instantAccessDurationMinutes
	 | 
		
			 
					integer
(int64)
			 
	minimum: 1
		 | 
	
		 För ögonblicksbilder som skapats från Premium SSD v2 eller Ultra-disk avgör den här egenskapen hur lång tid i minuter ögonblicksbilden behålls för omedelbar åtkomst för att möjliggöra snabbare återställning. 
	 | 
	| 
		logicalSectorSize
	 | 
		
			 
					integer
(int32)
			 
	
		 | 
	
		 Logisk sektorstorlek i byte för Ultra-diskar. Värden som stöds är 512 ad 4096. 4096 är standardvärdet. 
	 | 
	| 
		performancePlus
	 | 
		
			 
					boolean
			 
	
		 | 
	
		 Ange den här flaggan till true för att få en ökning av prestandamålet för den distribuerade disken, se här på respektive prestandamål. Den här flaggan kan bara anges när disken skapas och kan inte inaktiveras när den har aktiverats. 
	 | 
	| 
		provisionedBandwidthCopySpeed
	 | 
		
			 
					ProvisionedBandwidthCopyOption
			 
	
		 | 
	
		 Om det här fältet anges på en ögonblicksbild och createOption är CopyStart kopieras ögonblicksbilden snabbare. 
	 | 
	| 
		securityDataUri
	 | 
		
			 
					string
			 
	
		 | 
	
		 Om createOption är ImportSecure är detta URI för en blob som ska importeras till vm-gästtillstånd. 
	 | 
	| 
		securityMetadataUri
	 | 
		
			 
					string
(uri)
			 
	
		 | 
	
		 Om createOption är ImportSecure är detta URI:n för en blob som ska importeras till VM-metadata för konfidentiell virtuell dator. 
	 | 
	| 
		sourceResourceId
	 | 
		
			 
					string
			 
	
		 | 
	
		 Om createOption är Copy är detta ARM-ID för källögonblicksbilden eller disken. 
	 | 
	| 
		sourceUniqueId
	 | 
		
			 
					string
			 
	
		 | 
	
		 Om det här fältet har angetts är detta det unika ID som identifierar källan till den här resursen. 
	 | 
	| 
		sourceUri
	 | 
		
			 
					string
			 
	
		 | 
	
		 Om createOption är Import är detta URI för en blob som ska importeras till en hanterad disk. 
	 | 
	| 
		storageAccountId
	 | 
		
			 
					string
			 
	
		 | 
	
		 Krävs om createOption är Import. Azure Resource Manager-identifieraren för lagringskontot som innehåller bloben som ska importeras som en disk. 
	 | 
	| 
		uploadSizeBytes
	 | 
		
			 
					integer
(int64)
			 
	
		 | 
	
		 Om createOption är Upload är det här storleken på innehållet i uppladdningen, inklusive VHD-sidfoten. Det här värdet ska vara mellan 20972032 (20 MiB + 512 byte för VHD-sidfoten) och 35183298347520 byte (32 TiB + 512 byte för VHD-sidfoten). 
	 | 
				
			DataAccessAuthMode
			Uppräkning
			Ytterligare autentiseringskrav vid export eller uppladdning till en disk eller ögonblicksbild.
				
					
							| Värde | 
						Description | 
					
	| 
		AzureActiveDirectory
	 | 
	
		 När export-/uppladdnings-URL används kontrollerar systemet om användaren har en identitet i Azure Active Directory och har nödvändiga behörigheter för att exportera/ladda upp data. Se aka.ms/DisksAzureADAuth. 
	 | 
	| 
		None
	 | 
	
		 Ingen ytterligare autentisering utförs vid åtkomst till export-/uppladdnings-URL. 
	 | 
				
			Disk
			Objekt
			Disk resurs.
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		extendedLocation
	 | 
		
			 
					ExtendedLocation
			 
	
		 | 
	
		 Den utökade platsen där disken ska skapas. Det går inte att ändra den utökade platsen. 
	 | 
	| 
		id
	 | 
		
			 
					string
			 
	
		 | 
	
		 Fullständigt kvalificerat resurs-ID för resursen. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} 
	 | 
	| 
		location
	 | 
		
			 
					string
			 
	
		 | 
	
		 Den geo-plats där resursen finns 
	 | 
	| 
		managedBy
	 | 
		
			 
					string
			 
	
		 | 
	
		 En relativ URI som innehåller ID:t för den virtuella dator som har disken ansluten. 
	 | 
	| 
		managedByExtended
	 | 
		
			 
					string[]
			 
	
		 | 
	
		 Lista över relativa URI:er som innehåller ID:t för de virtuella datorer som har disken ansluten. maxShares ska anges till ett värde som är större än ett för diskar för att tillåta att de kopplas till flera virtuella datorer. 
	 | 
	| 
		name
	 | 
		
			 
					string
			 
	
		 | 
	
		 Namnet på resursen 
	 | 
	| 
		properties.LastOwnershipUpdateTime
	 | 
		
			 
					string
(date-time)
			 
	
		 | 
	
		 UTC-tiden när ägarskapstillståndet för disken senast ändrades, d.v.s. den tid då disken senast anslöts eller kopplades från en virtuell dator eller den tid då den virtuella dator som disken var ansluten till frigjordes eller startades. 
	 | 
	| 
		properties.availabilityPolicy
	 | 
		
			 
					AvailabilityPolicy
			 
	
		 | 
	
		 Avgör hur plattformen behandlar diskfel 
	 | 
	| 
		properties.burstingEnabled
	 | 
		
			 
					boolean
			 
	
		 | 
	
		 Ställ in på true för att aktivera burst-prestanda utöver diskens etablerade prestandamål. Bursting är inaktiverat som standard. Gäller inte för Ultra-diskar. 
	 | 
	| 
		properties.burstingEnabledTime
	 | 
		
			 
					string
(date-time)
			 
	
		 | 
	
		 Senaste gången när bursting senast aktiverades på en disk. 
	 | 
	| 
		properties.completionPercent
	 | 
		
			 
					number
(float)
			 
	
		 | 
	
		 Procent färdigt för bakgrundskopian när en resurs skapas via åtgärden CopyStart. 
	 | 
	| 
		properties.creationData
	 | 
		
			 
					CreationData
			 
	
		 | 
	
		 Information om diskkälla. CreationData-information kan inte ändras när disken har skapats. 
	 | 
	| 
		properties.dataAccessAuthMode
	 | 
		
			 
					DataAccessAuthMode
			 
	
		 | 
	
		 Ytterligare autentiseringskrav vid export eller uppladdning till en disk eller ögonblicksbild. 
	 | 
	| 
		properties.diskAccessId
	 | 
		
			 
					string
			 
	
		 | 
	
		 ARM-ID för DiskAccess-resursen för användning av privata slutpunkter på diskar. 
	 | 
	| 
		properties.diskIOPSReadOnly
	 | 
		
			 
					integer
(int64)
			 
	
		 | 
	
		 Det totala antalet IOPS som tillåts för alla virtuella datorer som monterar den delade disken som ReadOnly. En åtgärd kan överföra mellan 4k och 256 000 byte. 
	 | 
	| 
		properties.diskIOPSReadWrite
	 | 
		
			 
					integer
(int64)
			 
	
		 | 
	
		 Antalet tillåtna IOPS för den här disken. kan endast användas för UltraSSD-diskar. En åtgärd kan överföra mellan 4k och 256 000 byte. 
	 | 
	| 
		properties.diskMBpsReadOnly
	 | 
		
			 
					integer
(int64)
			 
	
		 | 
	
		 Det totala dataflödet (Mbit/s) som tillåts för alla virtuella datorer som monterar den delade disken som ReadOnly. Mbit/s innebär miljontals byte per sekund – MB använder här ISO-notationen, med krafter på 10. 
	 | 
	| 
		properties.diskMBpsReadWrite
	 | 
		
			 
					integer
(int64)
			 
	
		 | 
	
		 Den bandbredd som tillåts för den här disken. kan endast användas för UltraSSD-diskar. Mbit/s innebär miljontals byte per sekund – MB använder här ISO-notationen, med krafter på 10. 
	 | 
	| 
		properties.diskSizeBytes
	 | 
		
			 
					integer
(int64)
			 
	
		 | 
	
		 Storleken på disken i byte. Det här fältet är skrivskyddat. 
	 | 
	| 
		properties.diskSizeGB
	 | 
		
			 
					integer
(int32)
			 
	
		 | 
	
		 Om creationData.createOption är Tomt är det här fältet obligatoriskt och anger storleken på disken som ska skapas. Om det här fältet finns för uppdateringar eller skapande med andra alternativ, anger det en storleksändring. Storleksändring tillåts endast om disken inte är ansluten till en virtuell dator som körs och bara kan öka diskens storlek. 
	 | 
	| 
		properties.diskState
	 | 
		
			 
					DiskState
			 
	
		 | 
	
		 Diskens tillstånd. 
	 | 
	| 
		properties.encryption
	 | 
		
			 
					Encryption
			 
	
		 | 
	
		 Krypteringsegenskapen kan användas för att kryptera vilande data med kundhanterade nycklar eller plattformshanterade nycklar. 
	 | 
	| 
		properties.encryptionSettingsCollection
	 | 
		
			 
					EncryptionSettingsCollection
			 
	
		 | 
	
		 Krypteringsinställningar som används för Azure Disk Encryption kan innehålla flera krypteringsinställningar per disk eller ögonblicksbild. 
	 | 
	| 
		properties.hyperVGeneration
	 | 
		
			 
					HyperVGeneration
			 
	
		 | 
	
		 Hypervisor-genereringen av den virtuella datorn. Gäller endast os-diskar. 
	 | 
	| 
		properties.maxShares
	 | 
		
			 
					integer
(int32)
			 
	
		 | 
	
		 Det maximala antalet virtuella datorer som kan anslutas till disken samtidigt. Värdet större än ett anger en disk som kan monteras på flera virtuella datorer samtidigt. 
	 | 
	| 
		properties.networkAccessPolicy
	 | 
		
			 
					NetworkAccessPolicy
			 
	
		 | 
	
		 Princip för åtkomst till disken via nätverk. 
	 | 
	| 
		properties.optimizedForFrequentAttach
	 | 
		
			 
					boolean
			 
	
		 | 
	
		 Om du ställer in den här egenskapen på true förbättras tillförlitligheten och prestandan för datadiskar som ofta (mer än 5 gånger om dagen) kopplas från en virtuell dator och kopplas till en annan. Den här egenskapen bör inte anges för diskar som inte kopplas från och ansluts ofta eftersom det gör att diskarna inte överensstämmer med feldomänen för den virtuella datorn. 
	 | 
	| 
		properties.osType
	 | 
		
			 
					OperatingSystemTypes
			 
	
		 | 
	
		 Typ av operativsystem. 
	 | 
	| 
		properties.propertyUpdatesInProgress
	 | 
		
			 
					PropertyUpdatesInProgress
			 
	
		 | 
	
		 Egenskaper för den disk som uppdateringen väntar på. 
	 | 
	| 
		properties.provisioningState
	 | 
		
			 
					string
			 
	
		 | 
	
		 Tillståndet för disketablering. 
	 | 
	| 
		properties.publicNetworkAccess
	 | 
		
			 
					PublicNetworkAccess
			 
	
		 | 
	
		 Princip för att kontrollera exporten på disken. 
	 | 
	| 
		properties.purchasePlan
	 | 
		
			 
					DiskPurchasePlan
			 
	
		 | 
	
		 Köp planinformation för avbildningen från vilken OS-disken skapades. Till exempel - {name: 2019-Datacenter, utgivare: MicrosoftWindowsServer, produkt: WindowsServer} 
	 | 
	| 
		properties.securityProfile
	 | 
		
			 
					DiskSecurityProfile
			 
	
		 | 
	
		 Innehåller säkerhetsrelaterad information för resursen. 
	 | 
	| 
		properties.shareInfo
	 | 
		
			 
					ShareInfoElement[]
			 
	
		 | 
	
		 Information om listan över alla virtuella datorer som har disken ansluten. maxShares ska anges till ett värde som är större än ett för diskar för att tillåta att de kopplas till flera virtuella datorer. 
	 | 
	| 
		properties.supportedCapabilities
	 | 
		
			 
					SupportedCapabilities
			 
	
		 | 
	
		 Lista över funktioner som stöds för avbildningen från vilken OS-disken skapades. 
	 | 
	| 
		properties.supportsHibernation
	 | 
		
			 
					boolean
			 
	
		 | 
	
		 Anger att operativsystemet på en disk stöder viloläge. 
	 | 
	| 
		properties.tier
	 | 
		
			 
					string
			 
	
		 | 
	
		 Prestandanivån för disken (t.ex. P4, S10) enligt beskrivningen här: https://azure.microsoft.com/en-us/pricing/details/managed-disks/. Gäller inte för Ultra-diskar. 
	 | 
	| 
		properties.timeCreated
	 | 
		
			 
					string
(date-time)
			 
	
		 | 
	
		 Tiden då disken skapades. 
	 | 
	| 
		properties.uniqueId
	 | 
		
			 
					string
			 
	
		 | 
	
		 Unikt Guid som identifierar resursen. 
	 | 
	| 
		sku
	 | 
		
			 
					DiskSku
			 
	
		 | 
	
		 SKU-namnet för diskarna. Kan vara Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, StandardSSD_ZRS eller PremiumV2_LRS. 
	 | 
	| 
		systemData
	 | 
		
			 
					systemData
			 
	
		 | 
	
		 Azure Resource Manager-metadata som innehåller createdBy och modifiedBy information. 
	 | 
	| 
		tags
	 | 
		
			 
					object
			 
	
		 | 
	
		 Resursetiketter. 
	 | 
	| 
		type
	 | 
		
			 
					string
			 
	
		 | 
	
		 Resurstypen. T.ex. "Microsoft.Compute/virtualMachines" eller "Microsoft.Storage/storageAccounts" 
	 | 
	| 
		zones
	 | 
		
			 
					string[]
			 
	
		 | 
	
		 Listan Logisk zon för Disk. 
	 | 
				
			DiskCreateOption
			Uppräkning
			Detta räknar upp möjliga källor för att skapa en disk.
				
					
							| Värde | 
						Description | 
					
	| 
		Empty
	 | 
	
		 Skapa en tom datadisk med en storlek som anges av diskSizeGB. 
	 | 
	| 
		Attach
	 | 
	
		 Disken kommer att kopplas till en virtuell dator. 
	 | 
	| 
		FromImage
	 | 
	
		 Skapa en ny disk från en plattformsavbildning som anges av den angivna imageReference eller galleryImageReference. 
	 | 
	| 
		Import
	 | 
	
		 Skapa en disk genom att importera från en blob som anges av en sourceUri i ett lagringskonto som anges av storageAccountId. 
	 | 
	| 
		Copy
	 | 
	
		 Skapa en ny disk eller ögonblicksbild genom att kopiera från en disk eller ögonblicksbild som anges av det angivna sourceResourceId. 
	 | 
	| 
		Restore
	 | 
	
		 Skapa en ny disk genom att kopiera från en återställningspunkt för säkerhetskopiering. 
	 | 
	| 
		Upload
	 | 
	
		 Skapa en ny disk genom att hämta en skrivtoken och använda den för att direkt ladda upp innehållet på disken. 
	 | 
	| 
		CopyStart
	 | 
	
		 Skapa en ny disk med hjälp av en djupkopieringsprocess, där resursskapandet anses vara slutfört först när alla data har kopierats från källan. 
	 | 
	| 
		ImportSecure
	 | 
	
		 Liknar alternativet för att skapa import. Skapa en ny betrodd virtuell startdator eller en konfidentiell virtuell dator som stöds genom att importera ytterligare blobar för VM-gästtillstånd som anges av securityDataUri och VM-metadata som anges av securityMetadataUri i lagringskontot som anges av storageAccountId. Metadata för den virtuella datorn är valfria och krävs endast för vissa konfidentiella VM-konfigurationer och krävs inte för betrodd virtuell startdator. 
	 | 
	| 
		UploadPreparedSecure
	 | 
	
		 Liknar alternativet Ladda upp skapa. Skapa en ny disk som stöds av en betrodd startdator eller en konfidentiell virtuell dator och ladda upp med hjälp av skrivtoken på disken, gästtillståndet för den virtuella datorn och VM-metadata. Metadata för den virtuella datorn är valfria och krävs endast för vissa konfidentiella VM-konfigurationer och krävs inte för betrodd virtuell startdator. 
	 | 
	| 
		CopyFromSanSnapshot
	 | 
	
		 Skapa en ny disk genom att exportera från ögonblicksbild av elastisk SAN-volym 
	 | 
				
			DiskPurchasePlan
			Objekt
			Används för att fastställa inköpskontexten för en artefakt från tredje part via MarketPlace.
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		name
	 | 
		
			 
					string
			 
	
		 | 
	
		 Plan-ID:t. 
	 | 
	| 
		product
	 | 
		
			 
					string
			 
	
		 | 
	
		 Anger produkten av avbildningen från marketplace. Det här är samma värde som Erbjudandet under elementet imageReference. 
	 | 
	| 
		promotionCode
	 | 
		
			 
					string
			 
	
		 | 
	
		 Erbjudandehöjningskoden. 
	 | 
	| 
		publisher
	 | 
		
			 
					string
			 
	
		 | 
	
		 Utgivarens ID. 
	 | 
				
			DiskSecurityProfile
			Objekt
			Innehåller säkerhetsrelaterad information för resursen.
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		secureVMDiskEncryptionSetId
	 | 
		
			 
					string
			 
	
		 | 
	
		 ResourceId för diskkrypteringsuppsättningen som är associerad med konfidentiell virtuell dator som stöds disk krypterad med kundhanterad nyckel 
	 | 
	| 
		securityType
	 | 
		
			 
					DiskSecurityTypes
			 
	
		 | 
	
		 Anger SecurityType för den virtuella datorn. Gäller endast för OS-diskar. 
	 | 
				
			DiskSecurityTypes
			Uppräkning
			Anger SecurityType för den virtuella datorn. Gäller endast för OS-diskar.
				
					
							| Värde | 
						Description | 
					
	| 
		TrustedLaunch
	 | 
	
		 Betrodd start tillhandahåller säkerhetsfunktioner som säker start och virtuell vTPM (Trusted Platform Module) 
	 | 
	| 
		ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey
	 | 
	
		 Anger konfidentiell VM-disk med endast krypterat gästtillstånd för den virtuella datorn 
	 | 
	| 
		ConfidentialVM_DiskEncryptedWithPlatformKey
	 | 
	
		 Anger konfidentiell VM-disk med både OS-disk och VM-gästtillstånd krypterat med en plattformshanterad nyckel 
	 | 
	| 
		ConfidentialVM_DiskEncryptedWithCustomerKey
	 | 
	
		 Anger konfidentiell VM-disk med både OS-disk och VM-gästtillstånd krypterat med en kundhanterad nyckel 
	 | 
	| 
		ConfidentialVM_NonPersistedTPM
	 | 
	
		 Anger konfidentiell VM-disk med en tillfällig vTPM. vTPM-tillståndet bevaras inte vid omstart av virtuella datorer. 
	 | 
				
			DiskSku
			Objekt
			SKU-namnet för diskarna. Kan vara Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, StandardSSD_ZRS eller PremiumV2_LRS.
				
			DiskState
			Uppräkning
			Detta räknar upp diskens möjliga tillstånd.
				
					
							| Värde | 
						Description | 
					
	| 
		Unattached
	 | 
	
		 Disken används inte och kan kopplas till en virtuell dator. 
	 | 
	| 
		Attached
	 | 
	
		 Disken är för närvarande ansluten till en virtuell dator som körs. 
	 | 
	| 
		Reserved
	 | 
	
		 Disken är ansluten till en stoppad frigjord virtuell dator. 
	 | 
	| 
		Frozen
	 | 
	
		 Disken är ansluten till en virtuell dator som är i viloläge. 
	 | 
	| 
		ActiveSAS
	 | 
	
		 Disken har för närvarande en aktiv SAS-URI som är associerad med den. 
	 | 
	| 
		ActiveSASFrozen
	 | 
	
		 Disken är ansluten till en virtuell dator i viloläge och har en aktiv SAS-URI som är associerad med den. 
	 | 
	| 
		ReadyToUpload
	 | 
	
		 En disk är redo att skapas genom uppladdning genom att begära en skrivtoken. 
	 | 
	| 
		ActiveUpload
	 | 
	
		 En disk skapas för uppladdning och en skrivtoken har utfärdats för uppladdning till den. 
	 | 
				
			DiskStorageAccountTypes
			Uppräkning
			SKU-namnet.
				
					
							| Värde | 
						Description | 
					
	| 
		Standard_LRS
	 | 
	
		 Lokalt redundant lagring på Standard HDD. Bäst för säkerhetskopiering, icke-kritisk och ovanlig åtkomst. 
	 | 
	| 
		Premium_LRS
	 | 
	
		 Premium SSD lokalt redundant lagring. Bäst för produktions- och prestandakänsliga arbetsbelastningar. 
	 | 
	| 
		StandardSSD_LRS
	 | 
	
		 Lokalt redundant lagring med SSD som standard. Bäst för webbservrar, lätt använda företagsapplikationer och utveckling/testning. 
	 | 
	| 
		UltraSSD_LRS
	 | 
	
		 Ultra SSD lokalt redundant lagring. Bäst för I/O-intensiva arbetsbelastningar som SAP HANA, databaser på den översta nivån (till exempel SQL, Oracle) och andra transaktionsintensiva arbetsbelastningar. 
	 | 
	| 
		Premium_ZRS
	 | 
	
		 Premium SSD-zonredundant lagring. Bäst för produktionsarbetsbelastningar som behöver lagringsåterhämtning mot zonfel. 
	 | 
	| 
		StandardSSD_ZRS
	 | 
	
		 Zonredundant lagring som standard SSD. Bäst för webbservrar, lätt använda företagsprogram och utveckling/testning som behöver lagringsåterhämtning mot zonfel. 
	 | 
	| 
		PremiumV2_LRS
	 | 
	
		 Premium SSD v2 lokalt redundant lagring. Bäst för produktions- och prestandakänsliga arbetsbelastningar som konsekvent kräver låg latens och högt IOPS och dataflöde. 
	 | 
				
			Encryption
			Objekt
			Inställningar för kryptering i vila för disk eller ögonblicksbild
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		diskEncryptionSetId
	 | 
		
			 
					string
			 
	
		 | 
	
		 ResourceId för diskkrypteringsuppsättningen som ska användas för att aktivera kryptering i vila. 
	 | 
	| 
		type
	 | 
		
			 
					EncryptionType
			 
	
		 | 
	
		 Den typ av nyckel som används för att kryptera diskens data. 
	 | 
				
			EncryptionSettingsCollection
			Objekt
			Krypteringsinställningar för disk eller ögonblicksbild
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		enabled
	 | 
		
			 
					boolean
			 
	
		 | 
	
		 Ange den här flaggan till true och ange DiskEncryptionKey och valfri KeyEncryptionKey för att aktivera kryptering. Ange den här flaggan till false och ta bort DiskEncryptionKey och KeyEncryptionKey för att inaktivera kryptering. Om EncryptionSettings är null i begärandeobjektet förblir de befintliga inställningarna oförändrade. 
	 | 
	| 
		encryptionSettings
	 | 
		
			 
					EncryptionSettingsElement[]
			 
	
		 | 
	
		 En samling krypteringsinställningar, en för varje diskvolym. 
	 | 
	| 
		encryptionSettingsVersion
	 | 
		
			 
					string
			 
	
		 | 
	
		 Beskriver vilken typ av kryptering som används för diskarna. När det här fältet har angetts kan det inte skrivas över. "1.0" motsvarar Azure Disk Encryption med AAD-appen.'1.1' motsvarar Azure Disk Encryption. 
	 | 
				
			EncryptionSettingsElement
			Objekt
			Krypteringsinställningar för en diskvolym.
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		diskEncryptionKey
	 | 
		
			 
					KeyVaultAndSecretReference
			 
	
		 | 
	
		 Nyckelvalvshemlighets-URL och valv-ID för diskkrypteringsnyckeln 
	 | 
	| 
		keyEncryptionKey
	 | 
		
			 
					KeyVaultAndKeyReference
			 
	
		 | 
	
		 Key Vault-nyckel-URL och valv-ID för nyckelkrypteringsnyckeln. KeyEncryptionKey är valfritt och när det tillhandahålls används för att packa upp diskkrypteringsnyckeln. 
	 | 
				
			EncryptionType
			Uppräkning
			Den typ av nyckel som används för att kryptera diskens data.
				
					
							| Värde | 
						Description | 
					
	| 
		EncryptionAtRestWithPlatformKey
	 | 
	
		 Disken krypteras i vila med plattformshanterad nyckel. Det är standardkrypteringstypen. Det här är inte en giltig krypteringstyp för diskkrypteringsuppsättningar. 
	 | 
	| 
		EncryptionAtRestWithCustomerKey
	 | 
	
		 Disken krypteras i vila med en kundhanterad nyckel som kan ändras och återkallas av en kund. 
	 | 
	| 
		EncryptionAtRestWithPlatformAndCustomerKeys
	 | 
	
		 Disken krypteras i vila med 2 lager av kryptering. En av nycklarna är kundhanterad och den andra nyckeln är plattformshanterad. 
	 | 
				
			ExtendedLocation
			Objekt
			Den komplexa typen av utökad plats.
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		name
	 | 
		
			 
					string
			 
	
		 | 
	
		 Namnet på den utökade platsen. 
	 | 
	| 
		type
	 | 
		
			 
					ExtendedLocationTypes
			 
	
		 | 
	
		 Typ av utökad plats. 
	 | 
				
			ExtendedLocationTypes
			Uppräkning
			Typ av utökad plats.
				
					
							| Värde | 
						Description | 
					
	| 
		EdgeZone
	 | 
	
		
	 | 
				
			HyperVGeneration
			Uppräkning
			Hypervisor-genereringen av den virtuella datorn. Gäller endast os-diskar.
				
			ImageDiskReference
			Objekt
			Källavbildningen som används för att skapa disken.
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		communityGalleryImageId
	 | 
		
			 
					string
			 
	
		 | 
	
		 En relativ URI som innehåller en azure compute gallery-avbildningsreferens för communityn. 
	 | 
	| 
		id
	 | 
		
			 
					string
			 
	
		 | 
	
		 En relativ URI som innehåller antingen en plattformsbildlagringsplats, användarbild eller en bildreferens för Azure Compute Gallery. 
	 | 
	| 
		lun
	 | 
		
			 
					integer
(int32)
			 
	
		 | 
	
		 Om disken skapas från en avbildnings datadisk är detta ett index som anger vilken av datadiskarna i avbildningen som ska användas. För OS-diskar är det här fältet null. 
	 | 
	| 
		sharedGalleryImageId
	 | 
		
			 
					string
			 
	
		 | 
	
		 En relativ URI som innehåller en direkt delad Bildreferens för Azure Compute Gallery. 
	 | 
				
			InnerError
			Objekt
			Inre felinformation.
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		errordetail
	 | 
		
			 
					string
			 
	
		 | 
	
		 Det interna felmeddelandet eller undantagsdumpen. 
	 | 
	| 
		exceptiontype
	 | 
		
			 
					string
			 
	
		 | 
	
		 Typen av undantag. 
	 | 
				
			KeyVaultAndKeyReference
			Objekt
			Key Vault Key Url och valv-ID för KeK, KeK är valfritt och när det tillhandahålls används det för att packa upp encryptionKey
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		keyUrl
	 | 
		
			 
					string
			 
	
		 | 
	
		 Url som pekar på en nyckel eller hemlighet i KeyVault 
	 | 
	| 
		sourceVault
	 | 
		
			 
					SourceVault
			 
	
		 | 
	
		 Resurs-ID för KeyVault som innehåller nyckeln eller hemligheten 
	 | 
				
			KeyVaultAndSecretReference
			Objekt
			密钥保管库 hemlig URL och valv-ID för krypteringsnyckeln
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		secretUrl
	 | 
		
			 
					string
			 
	
		 | 
	
		 Url som pekar på en nyckel eller hemlighet i KeyVault 
	 | 
	| 
		sourceVault
	 | 
		
			 
					SourceVault
			 
	
		 | 
	
		 Resurs-ID för KeyVault som innehåller nyckeln eller hemligheten 
	 | 
				
			NetworkAccessPolicy
			Uppräkning
			Princip för åtkomst till disken via nätverk.
				
					
							| Värde | 
						Description | 
					
	| 
		AllowAll
	 | 
	
		 Disken kan exporteras eller laddas upp till från vilket nätverk som helst. 
	 | 
	| 
		AllowPrivate
	 | 
	
		 Disken kan exporteras eller laddas upp till med hjälp av en DiskAccess-resurs privata slutpunkter. 
	 | 
	| 
		DenyAll
	 | 
	
		 Det går inte att exportera disken. 
	 | 
				
			OperatingSystemTypes
			Uppräkning
			Typ av operativsystem.
				
					
							| Värde | 
						Description | 
					
	| 
		Windows
	 | 
	
		
	 | 
	| 
		Linux
	 | 
	
		
	 | 
				
			PropertyUpdatesInProgress
			Objekt
			Egenskaper för den disk som uppdateringen väntar på.
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		targetTier
	 | 
		
			 
					string
			 
	
		 | 
	
		 Målprestandanivån för disken om en nivåändringsåtgärd pågår. 
	 | 
				
			ProvisionedBandwidthCopyOption
			Uppräkning
			Om det här fältet anges på en ögonblicksbild och createOption är CopyStart kopieras ögonblicksbilden snabbare.
				
					
							| Värde | 
						Description | 
					
	| 
		None
	 | 
	
		
	 | 
	| 
		Enhanced
	 | 
	
		
	 | 
				
			PublicNetworkAccess
			Uppräkning
			Princip för att kontrollera exporten på disken.
				
					
							| Värde | 
						Description | 
					
	| 
		Enabled
	 | 
	
		 Du kan generera en SAS-URI för att komma åt underliggande data på disken offentligt på Internet när NetworkAccessPolicy är inställt på AllowAll. Du kan endast komma åt data via SAS-URI:n från ditt betrodda virtuella Azure-nätverk när NetworkAccessPolicy är inställt på AllowPrivate. 
	 | 
	| 
		Disabled
	 | 
	
		 Du kan inte komma åt underliggande data för disken offentligt på Internet även om NetworkAccessPolicy är inställt på AllowAll. Du kan endast komma åt data via SAS-URI:n från ditt betrodda virtuella Azure-nätverk när NetworkAccessPolicy är inställt på AllowPrivate. 
	 | 
				
			ShareInfoElement
			Objekt
			
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		vmUri
	 | 
		
			 
					string
			 
	
		 | 
	
		 En relativ URI som innehåller ID:t för den virtuella dator som har disken ansluten. 
	 | 
				
			SourceVault
			Objekt
			Valv-ID:t är ett Azure Resource Manager-resurs-ID i formatet /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		id
	 | 
		
			 
					string
			 
	
		 | 
	
		 Resurs-ID 
	 | 
				
			SupportedCapabilities
			Objekt
			Lista över funktioner som stöds som finns kvar på diskresursen för användning av virtuella datorer.
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		acceleratedNetwork
	 | 
		
			 
					boolean
			 
	
		 | 
	
		 Sant om avbildningen som OS-disken skapas från har stöd för accelererat nätverk. 
	 | 
	| 
		architecture
	 | 
		
			 
					Architecture
			 
	
		 | 
	
		 CPU-arkitektur som stöds av en OS-disk. 
	 | 
	| 
		diskControllerTypes
	 | 
		
			 
					string
			 
	
		 | 
	
		 De diskkontrollanter som en OS-disk stöder. Om den ställs in kan den vara SCSI eller SCSI, NVME eller NVME, SCSI. 
	 | 
	| 
		supportedSecurityOption
	 | 
		
			 
					SupportedSecurityOption
			 
	
		 | 
	
		 Refererar till säkerhetsfunktionen för den disk som stöds för att skapa en betrodd start eller konfidentiell virtuell dator 
	 | 
				
			SupportedSecurityOption
			Uppräkning
			Refererar till säkerhetsfunktionen för den disk som stöds för att skapa en betrodd start eller konfidentiell virtuell dator
				
					
							| Värde | 
						Description | 
					
	| 
		TrustedLaunchSupported
	 | 
	
		 Disken har stöd för att skapa betrodda virtuella startdatorer. 
	 | 
	| 
		TrustedLaunchAndConfidentialVMSupported
	 | 
	
		 Disken har stöd för att skapa både betrodd start och konfidentiella virtuella datorer. 
	 | 
				
			systemData
			Objekt
			Metadata som rör skapande och senaste ändring av resursen.
				
					
						    | Name | 
							Typ | 
						Description | 
					
	| 
		createdAt
	 | 
		
			 
					string
(date-time)
			 
	
		 | 
	
		 Tidsstämpeln för resursskapande (UTC). 
	 | 
	| 
		createdBy
	 | 
		
			 
					string
			 
	
		 | 
	
		 Identiteten som skapade resursen. 
	 | 
	| 
		createdByType
	 | 
		
			 
					createdByType
			 
	
		 | 
	
		 Den typ av identitet som skapade resursen. 
	 | 
	| 
		lastModifiedAt
	 | 
		
			 
					string
(date-time)
			 
	
		 | 
	
		 Tidsstämpeln för resursens senaste ändring (UTC) 
	 | 
	| 
		lastModifiedBy
	 | 
		
			 
					string
			 
	
		 | 
	
		 Identiteten som senast ändrade resursen. 
	 | 
	| 
		lastModifiedByType
	 | 
		
			 
					createdByType
			 
	
		 | 
	
		 Den typ av identitet som senast ändrade resursen. 
	 |