Возвращает список ключей API запросов для данной службы поиска.
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/listQueryKeys?api-version=2023-11-01
Параметры URI
Имя |
В |
Обязательно |
Тип |
Описание |
resourceGroupName
|
path |
True
|
string
|
Имя группы ресурсов в текущей подписке. Это значение можно получить из API Azure Resource Manager или портала.
|
searchServiceName
|
path |
True
|
string
|
Имя службы поиска, связанной с указанной группой ресурсов.
|
subscriptionId
|
path |
True
|
string
|
Уникальный идентификатор подписки Microsoft Azure. Это значение можно получить из API Azure Resource Manager, средств командной строки или портала.
|
api-version
|
query |
True
|
string
|
Версия API, используемая для каждого запроса.
|
Имя |
Обязательно |
Тип |
Описание |
x-ms-client-request-id
|
|
string
(uuid)
|
Значение GUID, созданное клиентом, идентифицирующее этот запрос. Если этот параметр указан, он будет включен в сведения о ответе в качестве способа отслеживания запроса.
|
Ответы
Имя |
Тип |
Описание |
200 OK
|
ListQueryKeysResult
|
Все ключи запросов для данной службы поиска были успешно извлечены и находятся в ответе. Вы можете использовать любой из ключей запроса в качестве значения параметра api-key в REST API плоскости данных или пакета SDK Azure для выполнения операций только для чтения в коллекции документов индексов поиска, таких как запросы и поиск документов по идентификатору.
|
Other Status Codes
|
CloudError
|
HTTP 404 (не найдено): не удалось найти подписку, группу ресурсов или службу поиска. HTTP 409 (конфликт): указанная подписка отключена.
|
Безопасность
azure_auth
Поток авторизации OAuth2 идентификатора Microsoft Entra ID.
Тип:
oauth2
Flow:
implicit
URL-адрес авторизации:
https://login.microsoftonline.com/common/oauth2/authorize
Области
Имя |
Описание |
user_impersonation
|
олицетворения учетной записи пользователя
|
Примеры
SearchListQueryKeysBySearchService
Образец запроса
POST https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice/listQueryKeys?api-version=2023-11-01
/**
* Samples for QueryKeys ListBySearchService.
*/
public final class Main {
/*
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/
* SearchListQueryKeysBySearchService.json
*/
/**
* Sample code: SearchListQueryKeysBySearchService.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void searchListQueryKeysBySearchService(com.azure.resourcemanager.AzureResourceManager azure) {
azure.searchServices().manager().serviceClient().getQueryKeys().listBySearchService("rg1", "mysearchservice",
null, 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.search import SearchManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-search
# USAGE
python search_list_query_keys_by_search_service.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 = SearchManagementClient(
credential=DefaultAzureCredential(),
subscription_id="subid",
)
response = client.query_keys.list_by_search_service(
resource_group_name="rg1",
search_service_name="mysearchservice",
)
for item in response:
print(item)
# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchListQueryKeysBySearchService.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 armsearch_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/search/armsearch"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7e29dd59eef13ef347d09e41a63f2585be77b3ca/specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchListQueryKeysBySearchService.json
func ExampleQueryKeysClient_NewListBySearchServicePager() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armsearch.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewQueryKeysClient().NewListBySearchServicePager("rg1", "mysearchservice", &armsearch.SearchManagementRequestOptions{ClientRequestID: nil}, nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.ListQueryKeysResult = armsearch.ListQueryKeysResult{
// Value: []*armsearch.QueryKey{
// {
// Name: to.Ptr("Query key for browser-based clients"),
// Key: to.Ptr("<a query API key>"),
// },
// {
// Name: to.Ptr("Query key for mobile clients"),
// Key: to.Ptr("<another query API key>"),
// }},
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { SearchManagementClient } = require("@azure/arm-search");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Returns the list of query API keys for the given Azure Cognitive Search service.
*
* @summary Returns the list of query API keys for the given Azure Cognitive Search service.
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchListQueryKeysBySearchService.json
*/
async function searchListQueryKeysBySearchService() {
const subscriptionId = process.env["SEARCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["SEARCH_RESOURCE_GROUP"] || "rg1";
const searchServiceName = "mysearchservice";
const credential = new DefaultAzureCredential();
const client = new SearchManagementClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.queryKeys.listBySearchService(
resourceGroupName,
searchServiceName
)) {
resArray.push(item);
}
console.log(resArray);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Search;
using Azure.ResourceManager.Search.Models;
// Generated from example definition: specification/search/resource-manager/Microsoft.Search/stable/2023-11-01/examples/SearchListQueryKeysBySearchService.json
// this example is just showing the usage of "QueryKeys_ListBySearchService" 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 SearchServiceResource created on azure
// for more information of creating SearchServiceResource, please refer to the document of SearchServiceResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
string searchServiceName = "mysearchservice";
ResourceIdentifier searchServiceResourceId = SearchServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, searchServiceName);
SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId);
// invoke the operation and iterate over the result
await foreach (SearchServiceQueryKey item in searchService.GetQueryKeysBySearchServiceAsync())
{
Console.WriteLine($"Succeeded: {item}");
}
Console.WriteLine($"Succeeded");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Пример ответа
{
"value": [
{
"name": "Query key for browser-based clients",
"key": "<a query API key>"
},
{
"name": "Query key for mobile clients",
"key": "<another query API key>"
}
]
}
Определения
Имя |
Описание |
CloudError
|
Содержит сведения об ошибке API.
|
CloudErrorBody
|
Описывает определенную ошибку API с кодом ошибки и сообщением.
|
ListQueryKeysResult
|
Ответ, содержащий ключи API запросов для данной службы поиска.
|
QueryKey
|
Описывает ключ API для данной службы поиска, которая имеет разрешения только для операций запроса.
|
CloudError
Object
Содержит сведения об ошибке API.
Имя |
Тип |
Описание |
error
|
CloudErrorBody
|
Описывает определенную ошибку API с кодом ошибки и сообщением.
|
CloudErrorBody
Object
Описывает определенную ошибку API с кодом ошибки и сообщением.
Имя |
Тип |
Описание |
code
|
string
|
Код ошибки, описывающий условие ошибки точнее, чем код состояния HTTP. Можно использовать для программной обработки конкретных случаев ошибок.
|
details
|
CloudErrorBody[]
|
Содержит вложенные ошибки, связанные с этой ошибкой.
|
message
|
string
|
Сообщение, описывающее ошибку подробно и предоставляющее сведения об отладке.
|
target
|
string
|
Целевой объект конкретной ошибки (например, имя свойства в ошибке).
|
ListQueryKeysResult
Object
Ответ, содержащий ключи API запросов для данной службы поиска.
Имя |
Тип |
Описание |
nextLink
|
string
|
URL-адрес запроса, который можно использовать для запроса следующей страницы ключей запросов. Возвращается, когда общее количество запрошенных ключей запросов превышает максимальный размер страницы.
|
value
|
QueryKey[]
|
Ключи запросов для службы поиска.
|
QueryKey
Object
Описывает ключ API для данной службы поиска, которая имеет разрешения только для операций запроса.
Имя |
Тип |
Описание |
key
|
string
|
Значение ключа API запроса.
|
name
|
string
|
Имя ключа API запроса; может быть пустым.
|