Obtenga las claves que se usarán con las API de Maps. Se usa una clave para autenticar y autorizar el acceso a las API REST de Maps. Sólo se necesita una clave a la vez; se proporcionan dos para proporcionar una regeneración de claves sin problemas.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/listKeys?api-version=2023-06-01
Parámetros de identificador URI
Nombre |
En |
Requerido |
Tipo |
Description |
accountName
|
path |
True
|
string
|
Nombre de la cuenta de Maps.
|
resourceGroupName
|
path |
True
|
string
|
Nombre del grupo de recursos. El nombre distingue mayúsculas de minúsculas.
|
subscriptionId
|
path |
True
|
string
|
Identificador de la suscripción de destino.
|
api-version
|
query |
True
|
string
|
Versión de API que se usará para la operación.
|
Respuestas
Nombre |
Tipo |
Description |
200 OK
|
MapsAccountKeys
|
La solicitud fue correcta.
|
Other Status Codes
|
ErrorResponse
|
Se ha producido un error inesperado.
|
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
List Keys
Solicitud de ejemplo
POST https://management.azure.com/subscriptions/21a9967a-e8a9-4656-a70b-96ff1c4d05a0/resourceGroups/myResourceGroup/providers/Microsoft.Maps/accounts/myMapsAccount/listKeys?api-version=2023-06-01
/** Samples for Accounts ListKeys. */
public final class Main {
/*
* x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/stable/2023-06-01/examples/ListKeys.json
*/
/**
* Sample code: List Keys.
*
* @param manager Entry point to AzureMapsManager.
*/
public static void listKeys(com.azure.resourcemanager.maps.AzureMapsManager manager) {
manager.accounts().listKeysWithResponse("myResourceGroup", "myMapsAccount", 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.maps import AzureMapsManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-maps
# USAGE
python list_keys.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 = AzureMapsManagementClient(
credential=DefaultAzureCredential(),
subscription_id="21a9967a-e8a9-4656-a70b-96ff1c4d05a0",
)
response = client.accounts.list_keys(
resource_group_name="myResourceGroup",
account_name="myMapsAccount",
)
print(response)
# x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/stable/2023-06-01/examples/ListKeys.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 armmaps_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/maps/armmaps"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b9403296f0b0e112b0d8222ad05fd1d79ee10e03/specification/maps/resource-manager/Microsoft.Maps/stable/2023-06-01/examples/ListKeys.json
func ExampleAccountsClient_ListKeys() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmaps.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewAccountsClient().ListKeys(ctx, "myResourceGroup", "myMapsAccount", nil)
if err != nil {
log.Fatalf("failed to finish the request: %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.AccountKeys = armmaps.AccountKeys{
// PrimaryKey: to.Ptr("<primaryKey>"),
// PrimaryKeyLastUpdated: to.Ptr("2021-07-02T01:01:01.1075056Z"),
// SecondaryKey: to.Ptr("<secondaryKey>"),
// SecondaryKeyLastUpdated: to.Ptr("2021-07-02T01:01:01.1075056Z"),
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { AzureMapsManagementClient } = require("@azure/arm-maps");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Get the keys to use with the Maps APIs. A key is used to authenticate and authorize access to the Maps REST APIs. Only one key is needed at a time; two are given to provide seamless key regeneration.
*
* @summary Get the keys to use with the Maps APIs. A key is used to authenticate and authorize access to the Maps REST APIs. Only one key is needed at a time; two are given to provide seamless key regeneration.
* x-ms-original-file: specification/maps/resource-manager/Microsoft.Maps/stable/2023-06-01/examples/ListKeys.json
*/
async function listKeys() {
const subscriptionId =
process.env["MAPS_SUBSCRIPTION_ID"] || "21a9967a-e8a9-4656-a70b-96ff1c4d05a0";
const resourceGroupName = process.env["MAPS_RESOURCE_GROUP"] || "myResourceGroup";
const accountName = "myMapsAccount";
const credential = new DefaultAzureCredential();
const client = new AzureMapsManagementClient(credential, subscriptionId);
const result = await client.accounts.listKeys(resourceGroupName, accountName);
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
Respuesta de muestra
{
"primaryKey": "<primaryKey>",
"primaryKeyLastUpdated": "2021-07-02T01:01:01.1075056Z",
"secondaryKey": "<secondaryKey>",
"secondaryKeyLastUpdated": "2021-07-02T01:01:01.1075056Z"
}
Definiciones
Nombre |
Description |
ErrorAdditionalInfo
|
Información adicional sobre el error de administración de recursos.
|
ErrorDetail
|
Detalle del error.
|
ErrorResponse
|
Respuesta de error
|
MapsAccountKeys
|
Conjunto de claves que se pueden usar para acceder a las API REST de Maps. Se proporcionan dos claves para la rotación de claves sin interrupción.
|
ErrorAdditionalInfo
Información adicional sobre el error de administración de recursos.
Nombre |
Tipo |
Description |
info
|
object
|
Información adicional.
|
type
|
string
|
Tipo de información adicional.
|
ErrorDetail
Detalle del error.
Nombre |
Tipo |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
Información adicional del error.
|
code
|
string
|
Código de error.
|
details
|
ErrorDetail[]
|
Los detalles del error.
|
message
|
string
|
El mensaje de error.
|
target
|
string
|
Destino del error.
|
ErrorResponse
Respuesta de error
Nombre |
Tipo |
Description |
error
|
ErrorDetail
|
Objeto de error.
|
MapsAccountKeys
Conjunto de claves que se pueden usar para acceder a las API REST de Maps. Se proporcionan dos claves para la rotación de claves sin interrupción.
Nombre |
Tipo |
Description |
primaryKey
|
string
|
Clave principal para acceder a las API REST de Maps.
|
primaryKeyLastUpdated
|
string
|
Fecha y hora actualizadas por última vez de la clave principal.
|
secondaryKey
|
string
|
Clave secundaria para acceder a las API REST de Maps.
|
secondaryKeyLastUpdated
|
string
|
Fecha y hora actualizadas por última vez de la clave secundaria.
|