Gewährt Zugriff auf einen Datenträger.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess?api-version=2023-10-02
URI-Parameter
Name |
In |
Erforderlich |
Typ |
Beschreibung |
diskName
|
path |
True
|
string
|
Der Name des verwalteten Datenträgers, der erstellt wird. Der Name kann nicht geändert werden, nachdem der Datenträger erstellt wurde. Unterstützte Zeichen für den Namen sind a-z, A-Z, 0-9, _ und -. Die maximale Namenslänge ist 80 Zeichen.
|
resourceGroupName
|
path |
True
|
string
|
Der Name der Ressourcengruppe.
|
subscriptionId
|
path |
True
|
string
|
Abonnementanmeldeinformationen, die das Microsoft Azure-Abonnement eindeutig identifizieren. Die Abonnement-ID ist Teil des URI für jeden Dienstaufruf.
|
api-version
|
query |
True
|
string
|
Client-API-Version.
|
Anforderungstext
Name |
Erforderlich |
Typ |
Beschreibung |
access
|
True
|
AccessLevel
|
|
durationInSeconds
|
True
|
integer
|
Zeitdauer in Sekunden, bis der SAS-Zugriff abläuft.
|
fileFormat
|
|
FileFormat
|
Wird verwendet, um das Dateiformat anzugeben, wenn sas für ein VHDX-Dateiformat Momentaufnahme
|
getSecureVMGuestStateSAS
|
|
boolean
|
Legen Sie dieses Flag auf true fest, um zusätzliche SAS für den VM-Gaststatus zu erhalten.
|
Antworten
Name |
Typ |
Beschreibung |
200 OK
|
AccessUri
|
OK
|
202 Accepted
|
|
Akzeptiert
|
Sicherheit
azure_auth
Azure Active Directory-OAuth2-Flow
Typ:
oauth2
Ablauf:
implicit
Autorisierungs-URL:
https://login.microsoftonline.com/common/oauth2/authorize
Bereiche
Name |
Beschreibung |
user_impersonation
|
Identitätswechsel Ihres Benutzerkontos
|
Beispiele
Get a sas on a managed disk.
Beispielanforderung
POST https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk/beginGetAccess?api-version=2023-10-02
{
"access": "Read",
"durationInSeconds": 300,
"fileFormat": "VHD"
}
import com.azure.resourcemanager.compute.models.AccessLevel;
import com.azure.resourcemanager.compute.models.FileFormat;
import com.azure.resourcemanager.compute.models.GrantAccessData;
/**
* Samples for Disks GrantAccess.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/
* Disk_BeginGetAccess.json
*/
/**
* Sample code: Get a sas on a managed disk.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void getASasOnAManagedDisk(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getDisks().grantAccess("myResourceGroup", "myDisk",
new GrantAccessData().withAccess(AccessLevel.READ).withDurationInSeconds(300)
.withFileFormat(FileFormat.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
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/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/81a4ee5a83ae38620c0e1404793caffe005d26e4/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_BeginGetAccess.json
func ExampleDisksClient_BeginGrantAccess_getASasOnAManagedDisk() {
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().BeginGrantAccess(ctx, "myResourceGroup", "myDisk", armcompute.GrantAccessData{
Access: to.Ptr(armcompute.AccessLevelRead),
DurationInSeconds: to.Ptr[int32](300),
FileFormat: to.Ptr(armcompute.FileFormatVHD),
}, 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.AccessURI = armcompute.AccessURI{
// AccessSAS: to.Ptr("https://md-gpvmcxzlzxgd.partition.blob.storage.azure.net/xx3cqcx53f0v/abcd?sv=2014-02-14&sr=b&sk=key1&sig=XXX&st=2021-05-24T18:02:34Z&se=2021-05-24T18:19:14Z&sp=r"),
// }
}
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");
/**
* This sample demonstrates how to Grants access to a disk.
*
* @summary Grants access to a disk.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_BeginGetAccess.json
*/
async function getASasOnAManagedDisk() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const diskName = "myDisk";
const grantAccessData = {
access: "Read",
durationInSeconds: 300,
fileFormat: "VHD",
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.disks.beginGrantAccessAndWait(
resourceGroupName,
diskName,
grantAccessData,
);
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.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_BeginGetAccess.json
// this example is just showing the usage of "Disks_GrantAccess" 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://learn.microsoft.com/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 ManagedDiskResource created on azure
// for more information of creating ManagedDiskResource, please refer to the document of ManagedDiskResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
string diskName = "myDisk";
ResourceIdentifier managedDiskResourceId = ManagedDiskResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, diskName);
ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId);
// invoke the operation
GrantAccessData data = new GrantAccessData(AccessLevel.Read, 300)
{
FileFormat = DiskImageFileFormat.Vhd,
};
ArmOperation<AccessUri> lro = await managedDisk.GrantAccessAsync(WaitUntil.Completed, data);
AccessUri result = lro.Value;
Console.WriteLine($"Succeeded: {result}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Beispiel für eine Antwort
{
"accessSAS": "https://md-gpvmcxzlzxgd.partition.blob.storage.azure.net/xx3cqcx53f0v/abcd?sv=2014-02-14&sr=b&sk=key1&sig=XXX&st=2021-05-24T18:02:34Z&se=2021-05-24T18:19:14Z&sp=r"
}
Location: https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/operations/{operationId}&monitor=true&api-version=2023-10-02
Get sas on managed disk and VM guest state
Beispielanforderung
POST https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk/beginGetAccess?api-version=2023-10-02
{
"access": "Read",
"durationInSeconds": 300,
"getSecureVMGuestStateSAS": true
}
import com.azure.resourcemanager.compute.models.AccessLevel;
import com.azure.resourcemanager.compute.models.GrantAccessData;
/**
* Samples for Disks GrantAccess.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/
* Disk_BeginGetAccess_WithVMGuestState.json
*/
/**
* Sample code: Get sas on managed disk and VM guest state.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void getSasOnManagedDiskAndVMGuestState(com.azure.resourcemanager.AzureResourceManager azure) {
azure.virtualMachines().manager().serviceClient().getDisks().grantAccess("myResourceGroup", "myDisk",
new GrantAccessData().withAccess(AccessLevel.READ).withDurationInSeconds(300)
.withGetSecureVMGuestStateSas(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
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/v6"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/81a4ee5a83ae38620c0e1404793caffe005d26e4/specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_BeginGetAccess_WithVMGuestState.json
func ExampleDisksClient_BeginGrantAccess_getSasOnManagedDiskAndVmGuestState() {
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().BeginGrantAccess(ctx, "myResourceGroup", "myDisk", armcompute.GrantAccessData{
Access: to.Ptr(armcompute.AccessLevelRead),
DurationInSeconds: to.Ptr[int32](300),
GetSecureVMGuestStateSAS: 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.AccessURI = armcompute.AccessURI{
// AccessSAS: to.Ptr("https://md-gpvmcxzlzxgd.partition.blob.storage.azure.net/xx3cqcx53f0v/abcd?sv=2014-02-14&sr=b&sk=key1&sig=XXX&st=2021-05-24T18:02:34Z&se=2021-05-24T18:19:14Z&sp=r"),
// SecurityDataAccessSAS: to.Ptr("https://md-gpvmcxzlzxgd.partition.blob.storage.azure.net/xx3cqcx53f0v/b9bf5824-6122-49e0-ba22-042f76ccd8a1_vmgs?sv=2014-02-14&sr=b&sk=key1&sig=XXX&st=2021-05-24T18:02:34Z&se=2021-05-24T18:19:14Z&sp=r"),
// }
}
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");
/**
* This sample demonstrates how to Grants access to a disk.
*
* @summary Grants access to a disk.
* x-ms-original-file: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_BeginGetAccess_WithVMGuestState.json
*/
async function getSasOnManagedDiskAndVMGuestState() {
const subscriptionId = process.env["COMPUTE_SUBSCRIPTION_ID"] || "{subscription-id}";
const resourceGroupName = process.env["COMPUTE_RESOURCE_GROUP"] || "myResourceGroup";
const diskName = "myDisk";
const grantAccessData = {
access: "Read",
durationInSeconds: 300,
getSecureVMGuestStateSAS: true,
};
const credential = new DefaultAzureCredential();
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.disks.beginGrantAccessAndWait(
resourceGroupName,
diskName,
grantAccessData,
);
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.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2023-10-02/examples/diskExamples/Disk_BeginGetAccess_WithVMGuestState.json
// this example is just showing the usage of "Disks_GrantAccess" 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://learn.microsoft.com/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 ManagedDiskResource created on azure
// for more information of creating ManagedDiskResource, please refer to the document of ManagedDiskResource
string subscriptionId = "{subscription-id}";
string resourceGroupName = "myResourceGroup";
string diskName = "myDisk";
ResourceIdentifier managedDiskResourceId = ManagedDiskResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, diskName);
ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId);
// invoke the operation
GrantAccessData data = new GrantAccessData(AccessLevel.Read, 300)
{
GetSecureVmGuestStateSas = true,
};
ArmOperation<AccessUri> lro = await managedDisk.GrantAccessAsync(WaitUntil.Completed, data);
AccessUri result = lro.Value;
Console.WriteLine($"Succeeded: {result}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Beispiel für eine Antwort
{
"accessSAS": "https://md-gpvmcxzlzxgd.partition.blob.storage.azure.net/xx3cqcx53f0v/abcd?sv=2014-02-14&sr=b&sk=key1&sig=XXX&st=2021-05-24T18:02:34Z&se=2021-05-24T18:19:14Z&sp=r",
"securityDataAccessSAS": "https://md-gpvmcxzlzxgd.partition.blob.storage.azure.net/xx3cqcx53f0v/b9bf5824-6122-49e0-ba22-042f76ccd8a1_vmgs?sv=2014-02-14&sr=b&sk=key1&sig=XXX&st=2021-05-24T18:02:34Z&se=2021-05-24T18:19:14Z&sp=r"
}
Location: https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/operations/{operationId}&monitor=true&api-version=2023-10-02
Definitionen
Name |
Beschreibung |
AccessLevel
|
|
AccessUri
|
Ein SAS-URI für den Datenträgerzugriff.
|
FileFormat
|
Wird verwendet, um das Dateiformat anzugeben, wenn sas für ein VHDX-Dateiformat Momentaufnahme
|
GrantAccessData
|
Daten, die zum Anfordern einer SAS verwendet werden.
|
AccessLevel
Name |
Typ |
Beschreibung |
None
|
string
|
|
Read
|
string
|
|
Write
|
string
|
|
AccessUri
Ein SAS-URI für den Datenträgerzugriff.
Name |
Typ |
Beschreibung |
accessSAS
|
string
|
Ein SAS-URI für den Zugriff auf einen Datenträger.
|
securityDataAccessSAS
|
string
|
Ein SAS-URI für den Zugriff auf einen VM-Gaststatus.
|
Wird verwendet, um das Dateiformat anzugeben, wenn sas für ein VHDX-Dateiformat Momentaufnahme
Name |
Typ |
Beschreibung |
VHD
|
string
|
Eine VHD-Datei ist eine Datenträgerimagedatei im Dateiformat "Virtuelle Festplatte".
|
VHDX
|
string
|
Eine VHDX-Datei ist eine Datenträgerimagedatei im Dateiformat Virtual Hard Disk v2.
|
GrantAccessData
Daten, die zum Anfordern einer SAS verwendet werden.
Name |
Typ |
Beschreibung |
access
|
AccessLevel
|
|
durationInSeconds
|
integer
|
Zeitdauer in Sekunden, bis der SAS-Zugriff abläuft.
|
fileFormat
|
FileFormat
|
Wird verwendet, um das Dateiformat anzugeben, wenn sas für ein VHDX-Dateiformat Momentaufnahme
|
getSecureVMGuestStateSAS
|
boolean
|
Legen Sie dieses Flag auf true fest, um zusätzliche SAS für den VM-Gaststatus zu erhalten.
|