Concede acceso a un disco.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess?api-version=2023-10-02
Parámetros de identificador URI
Nombre |
En |
Requerido |
Tipo |
Description |
diskName
|
path |
True
|
string
|
Nombre del disco administrado que se está creando. El nombre no se puede cambiar después de crear el disco. Los caracteres admitidos para el nombre son a-z, A-Z, 0-9, _ y -. La longitud máxima del nombre es de 80 caracteres.
|
resourceGroupName
|
path |
True
|
string
|
Nombre del grupo de recursos.
|
subscriptionId
|
path |
True
|
string
|
Credenciales de suscripción que identifican de forma única la suscripción de Microsoft Azure. El identificador de suscripción forma parte del URI para cada llamada al servicio.
|
api-version
|
query |
True
|
string
|
Versión de api de cliente.
|
Cuerpo de la solicitud
Nombre |
Requerido |
Tipo |
Description |
access
|
True
|
AccessLevel
|
|
durationInSeconds
|
True
|
integer
|
Duración del tiempo en segundos hasta que expire el acceso de SAS.
|
fileFormat
|
|
FileFormat
|
Se usa para especificar el formato de archivo al realizar una solicitud de SAS en una instantánea de formato de archivo VHDX
|
getSecureVMGuestStateSAS
|
|
boolean
|
Establezca esta marca en true para obtener SAS adicional para el estado de invitado de la máquina virtual.
|
Respuestas
Nombre |
Tipo |
Description |
200 OK
|
AccessUri
|
Aceptar
|
202 Accepted
|
|
Aceptado
|
Seguridad
azure_auth
Flujo OAuth2 de Azure Active Directory
Tipo:
oauth2
Flujo:
implicit
Dirección URL de autorización:
https://login.microsoftonline.com/common/oauth2/authorize
Ámbitos
Nombre |
Description |
user_impersonation
|
suplantación de su cuenta de usuario
|
Ejemplos
Get a sas on a managed disk.
Solicitud de ejemplo
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
Respuesta de muestra
{
"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
Solicitud de ejemplo
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
Respuesta de muestra
{
"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
Definiciones
Nombre |
Description |
AccessLevel
|
|
AccessUri
|
Un URI de SAS de acceso al disco.
|
FileFormat
|
Se usa para especificar el formato de archivo al realizar una solicitud de SAS en una instantánea de formato de archivo VHDX
|
GrantAccessData
|
Datos usados para solicitar una SAS.
|
AccessLevel
Nombre |
Tipo |
Description |
None
|
string
|
|
Read
|
string
|
|
Write
|
string
|
|
AccessUri
Un URI de SAS de acceso al disco.
Nombre |
Tipo |
Description |
accessSAS
|
string
|
Un URI de SAS para acceder a un disco.
|
securityDataAccessSAS
|
string
|
Un URI de SAS para acceder a un estado de invitado de máquina virtual.
|
Se usa para especificar el formato de archivo al realizar una solicitud de SAS en una instantánea de formato de archivo VHDX
Nombre |
Tipo |
Description |
VHD
|
string
|
Un archivo VHD es un archivo de imagen de disco en el formato de archivo de disco duro virtual.
|
VHDX
|
string
|
Un archivo VHDX es un archivo de imagen de disco en el formato de archivo disco duro virtual v2.
|
GrantAccessData
Datos usados para solicitar una SAS.
Nombre |
Tipo |
Description |
access
|
AccessLevel
|
|
durationInSeconds
|
integer
|
Duración del tiempo en segundos hasta que expire el acceso de SAS.
|
fileFormat
|
FileFormat
|
Se usa para especificar el formato de archivo al realizar una solicitud de SAS en una instantánea de formato de archivo VHDX
|
getSecureVMGuestStateSAS
|
boolean
|
Establezca esta marca en true para obtener SAS adicional para el estado de invitado de la máquina virtual.
|