指定した Azure Cosmos DB データベース アカウントの読み取り専用アクセス キーをListsします。
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys?api-version=2023-11-15
URI パラメーター
名前 |
/ |
必須 |
型 |
説明 |
accountName
|
path |
True
|
string
|
Cosmos DB データベース アカウント名。
Regex pattern: ^[a-z0-9]+(-[a-z0-9]+)*
|
resourceGroupName
|
path |
True
|
string
|
リソース グループの名前。 名前の大文字と小文字は区別されます。
|
subscriptionId
|
path |
True
|
string
|
ターゲット サブスクリプションの ID。
|
api-version
|
query |
True
|
string
|
この操作に使用する API バージョン。
|
応答
セキュリティ
azure_auth
Azure Active Directory OAuth2 フロー
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
名前 |
説明 |
user_impersonation
|
ユーザー アカウントの借用
|
例
CosmosDBDatabaseAccountListReadOnlyKeys
Sample Request
GET https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/ddb1/readonlykeys?api-version=2023-11-15
/**
* Samples for DatabaseAccounts ListReadOnlyKeys.
*/
public final class Main {
/*
* x-ms-original-file: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2023-11-15/examples/
* CosmosDBDatabaseAccountListReadOnlyKeys.json
*/
/**
* Sample code: CosmosDBDatabaseAccountListReadOnlyKeys.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void cosmosDBDatabaseAccountListReadOnlyKeys(com.azure.resourcemanager.AzureResourceManager azure) {
azure.cosmosDBAccounts().manager().serviceClient().getDatabaseAccounts().listReadOnlyKeysWithResponse("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_read_only_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.get_read_only_keys(
resource_group_name="rg1",
account_name="ddb1",
)
print(response)
# x-ms-original-file: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2023-11-15/examples/CosmosDBDatabaseAccountListReadOnlyKeys.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/v2"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/41e4538ed7bb3ceac3c1322c9455a0812ed110ac/specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2023-11-15/examples/CosmosDBDatabaseAccountListReadOnlyKeys.json
func ExampleDatabaseAccountsClient_GetReadOnlyKeys() {
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().GetReadOnlyKeys(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.DatabaseAccountListReadOnlyKeysResult = armcosmos.DatabaseAccountListReadOnlyKeysResult{
// PrimaryReadonlyMasterKey: to.Ptr("primaryReadonlyMasterKey"),
// SecondaryReadonlyMasterKey: to.Ptr("secondaryReadonlyMasterKey"),
// }
}
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 read-only access keys for the specified Azure Cosmos DB database account.
*
* @summary Lists the read-only access keys for the specified Azure Cosmos DB database account.
* x-ms-original-file: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/stable/2023-11-15/examples/CosmosDBDatabaseAccountListReadOnlyKeys.json
*/
async function cosmosDbDatabaseAccountListReadOnlyKeys() {
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.getReadOnlyKeys(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
Sample Response
{
"primaryReadonlyMasterKey": "primaryReadonlyMasterKey",
"secondaryReadonlyMasterKey": "secondaryReadonlyMasterKey"
}
定義
DatabaseAccountListReadOnlyKeysResult
指定されたデータベース アカウントの読み取り専用アクセス キー。
名前 |
型 |
説明 |
primaryReadonlyMasterKey
|
string
|
プライマリ読み取り専用キーの Base 64 エンコード値。
|
secondaryReadonlyMasterKey
|
string
|
セカンダリ読み取り専用キーの Base 64 エンコード値。
|