Seznamy přístupové klíče pro zadaný účet databáze Azure Cosmos DB.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys?api-version=2024-05-15
Parametry identifikátoru URI
Name |
V |
Vyžadováno |
Typ |
Description |
accountName
|
path |
True
|
string
|
Název databázového účtu služby Cosmos DB.
Vzor regulárního výrazu: ^[a-z0-9]+(-[a-z0-9]+)*
|
resourceGroupName
|
path |
True
|
string
|
Název skupiny prostředků. V názvu se rozlišují malá a velká písmena.
|
subscriptionId
|
path |
True
|
string
|
ID cílového předplatného.
|
api-version
|
query |
True
|
string
|
Verze rozhraní API, která se má použít pro tuto operaci.
|
Odpovědi
Zabezpečení
azure_auth
Tok Azure Active Directory OAuth2
Typ:
oauth2
Tok:
implicit
URL autorizace:
https://login.microsoftonline.com/common/oauth2/authorize
Rozsahy
Name |
Description |
user_impersonation
|
Zosobnění uživatelského účtu
|
Příklady
CosmosDBDatabaseAccountListKeys
Ukázkový požadavek
POST https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/ddb1/listKeys?api-version=2024-05-15
/**
* Samples for DatabaseAccounts ListKeys.
*/
public final class Main {
/*
* x-ms-original-file: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2024-05-15/examples/
* CosmosDBDatabaseAccountListKeys.json
*/
/**
* Sample code: CosmosDBDatabaseAccountListKeys.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void cosmosDBDatabaseAccountListKeys(com.azure.resourcemanager.AzureResourceManager azure) {
azure.cosmosDBAccounts().manager().serviceClient().getDatabaseAccounts().listKeysWithResponse("rg1", "ddb1",
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.cosmosdb import CosmosDBManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-cosmosdb
# USAGE
python cosmos_db_database_account_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 = CosmosDBManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.database_accounts.list_keys(
resource_group_name="rg1",
account_name="ddb1",
)
print(response)
# x-ms-original-file: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2024-05-15/examples/CosmosDBDatabaseAccountListKeys.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 armcosmos_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos/v3"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/ec7ee8842bf615c2f0354bf8b5b8725fdac9454a/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2024-05-15/examples/CosmosDBDatabaseAccountListKeys.json
func ExampleDatabaseAccountsClient_ListKeys() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcosmos.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewDatabaseAccountsClient().ListKeys(ctx, "rg1", "ddb1", 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.DatabaseAccountListKeysResult = armcosmos.DatabaseAccountListKeysResult{
// PrimaryReadonlyMasterKey: to.Ptr("primaryReadonlyMasterKey"),
// SecondaryReadonlyMasterKey: to.Ptr("secondaryReadonlyMasterKey"),
// PrimaryMasterKey: to.Ptr("primaryMasterKey"),
// SecondaryMasterKey: to.Ptr("secondaryMasterKey"),
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CosmosDBManagementClient } = require("@azure/arm-cosmosdb");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Lists the access keys for the specified Azure Cosmos DB database account.
*
* @summary Lists the access keys for the specified Azure Cosmos DB database account.
* x-ms-original-file: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2024-05-15/examples/CosmosDBDatabaseAccountListKeys.json
*/
async function cosmosDbDatabaseAccountListKeys() {
const subscriptionId = process.env["COSMOSDB_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["COSMOSDB_RESOURCE_GROUP"] || "rg1";
const accountName = "ddb1";
const credential = new DefaultAzureCredential();
const client = new CosmosDBManagementClient(credential, subscriptionId);
const result = await client.databaseAccounts.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
Ukázková odpověď
{
"primaryMasterKey": "primaryMasterKey",
"secondaryMasterKey": "secondaryMasterKey",
"primaryReadonlyMasterKey": "primaryReadonlyMasterKey",
"secondaryReadonlyMasterKey": "secondaryReadonlyMasterKey"
}
Definice
DatabaseAccountListKeysResult
Přístupové klíče pro daný databázový účet.
Name |
Typ |
Description |
primaryMasterKey
|
string
|
Základní 64 kódovaná hodnota primárního klíče pro čtení a zápis.
|
primaryReadonlyMasterKey
|
string
|
Základní 64 kódovaná hodnota primárního klíče jen pro čtení
|
secondaryMasterKey
|
string
|
Základní 64 kódovaná hodnota sekundárního klíče pro čtení a zápis.
|
secondaryReadonlyMasterKey
|
string
|
Základní 64 kódovaná hodnota sekundárního klíče jen pro čtení.
|