Concede acesso a um disco.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess?api-version=2023-10-02
Parâmetros de URI
Nome |
Em |
Obrigatório |
Tipo |
Description |
diskName
|
path |
True
|
string
|
O nome do disco gerenciado que está sendo criado. O nome não pode ser alterado depois que o disco é criado. Os caracteres com suporte para o nome são a-z, A-Z, 0-9, _ e -. O tamanho máximo do nome é de 80 caracteres.
|
resourceGroupName
|
path |
True
|
string
|
O nome do grupo de recursos.
|
subscriptionId
|
path |
True
|
string
|
Credenciais de assinatura que identificam exclusivamente a assinatura do Microsoft Azure. A ID da assinatura faz parte do URI para cada chamada de serviço.
|
api-version
|
query |
True
|
string
|
Versão da API do cliente.
|
Corpo da solicitação
Nome |
Obrigatório |
Tipo |
Description |
access
|
True
|
AccessLevel
|
|
durationInSeconds
|
True
|
integer
|
Duração do tempo em segundos até que o acesso sas expire.
|
fileFormat
|
|
FileFormat
|
Usado para especificar o formato de arquivo ao fazer uma solicitação para SAS em um formato de arquivo VHDX instantâneo
|
getSecureVMGuestStateSAS
|
|
boolean
|
Defina esse sinalizador como true para obter SAS adicional para o estado de convidado da VM
|
Respostas
Nome |
Tipo |
Description |
200 OK
|
AccessUri
|
OK
|
202 Accepted
|
|
Aceito
|
Segurança
azure_auth
Fluxo do OAuth2 do Azure Active Directory
Tipo:
oauth2
Flow:
implicit
URL de Autorização:
https://login.microsoftonline.com/common/oauth2/authorize
Escopos
Nome |
Description |
user_impersonation
|
representar sua conta de usuário
|
Exemplos
Get a sas on a managed disk.
Solicitação de exemplo
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://video2.skills-academy.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
Resposta de exemplo
{
"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
Solicitação de exemplo
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://video2.skills-academy.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
Resposta de exemplo
{
"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
Definições
Nome |
Description |
AccessLevel
|
|
AccessUri
|
Um uri SAS de acesso ao disco.
|
FileFormat
|
Usado para especificar o formato de arquivo ao fazer uma solicitação para SAS em um formato de arquivo VHDX instantâneo
|
GrantAccessData
|
Dados usados para solicitar uma SAS.
|
AccessLevel
Nome |
Tipo |
Description |
None
|
string
|
|
Read
|
string
|
|
Write
|
string
|
|
AccessUri
Um uri SAS de acesso ao disco.
Nome |
Tipo |
Description |
accessSAS
|
string
|
Um uri SAS para acessar um disco.
|
securityDataAccessSAS
|
string
|
Um uri SAS para acessar um estado convidado de VM.
|
Usado para especificar o formato de arquivo ao fazer uma solicitação para SAS em um formato de arquivo VHDX instantâneo
Nome |
Tipo |
Description |
VHD
|
string
|
Um arquivo VHD é um arquivo de imagem de disco no formato de arquivo disco rígido virtual.
|
VHDX
|
string
|
Um arquivo VHDX é um arquivo de imagem de disco no formato de arquivo disco rígido virtual v2.
|
GrantAccessData
Dados usados para solicitar uma SAS.
Nome |
Tipo |
Description |
access
|
AccessLevel
|
|
durationInSeconds
|
integer
|
Duração do tempo em segundos até que o acesso sas expire.
|
fileFormat
|
FileFormat
|
Usado para especificar o formato de arquivo ao fazer uma solicitação para SAS em um formato de arquivo VHDX instantâneo
|
getSecureVMGuestStateSAS
|
boolean
|
Defina esse sinalizador como true para obter SAS adicional para o estado de convidado da VM
|