在给定资源组中创建或更新搜索服务。 如果搜索服务已存在,则会使用给定的值更新所有属性。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}?api-version=2025-05-01
URI 参数
| 名称 |
在 |
必需 |
类型 |
说明 |
|
resourceGroupName
|
path |
True
|
string
|
当前订阅中的资源组的名称。 可以从 Azure 资源管理器 API 或门户获取此值。
|
|
searchServiceName
|
path |
True
|
string
|
要创建或更新的 Azure AI 搜索服务的名称。 搜索服务名称只能包含小写字母、数字或短划线,不能使用短划线作为前两个字符或最后一个字符,不能包含连续短划线,长度必须介于 2 到 60 个字符之间。 搜索服务名称必须是唯一的,因为它们是服务 URI (https://< name.search.windows.net>) 的一部分。 创建服务后,无法更改服务名称。
|
|
subscriptionId
|
path |
True
|
string
|
Microsoft Azure 订阅的唯一标识符。 可以从 Azure 资源管理器 API 或门户获取此值。
|
|
api-version
|
query |
True
|
string
|
要用于每个请求的 API 版本。
|
| 名称 |
必需 |
类型 |
说明 |
|
x-ms-client-request-id
|
|
string
(uuid)
|
一个客户端生成的 GUID 值,用于标识此请求。 如果指定,响应信息中将包含此内容作为跟踪请求的一种方式。
|
请求正文
| 名称 |
必需 |
类型 |
说明 |
|
location
|
True
|
string
|
资源所在的地理位置
|
|
identity
|
|
Identity
|
资源的标识。
|
|
properties.authOptions
|
|
DataPlaneAuthOptions
|
定义搜索服务的数据平面 API 如何对请求进行身份验证的选项。 如果“disableLocalAuth”设置为 true,则无法设置此项。
|
|
properties.computeType
|
|
ComputeType
|
配置此属性以支持使用默认计算或 Azure 机密计算的搜索服务。
|
|
properties.dataExfiltrationProtections
|
|
SearchDataExfiltrationProtection[]
|
显式禁止搜索服务的数据外泄方案列表。 目前,唯一支持的值是“全部”,用于禁用所有可能的数据导出方案,并计划将来进行更精细的控制。
|
|
properties.disableLocalAuth
|
|
boolean
|
如果设置为 true,则不允许调用搜索服务以使用 API 密钥进行身份验证。 如果定义了“dataPlaneAuthOptions”,则无法将其设置为 true。
|
|
properties.encryptionWithCmk
|
|
EncryptionWithCmk
|
指定有关使用搜索服务中的客户经理密钥加密资源(如索引)的任何策略。
|
|
properties.endpoint
|
|
string
(uri)
|
Azure AI 搜索服务的终结点。
|
|
properties.hostingMode
|
|
HostingMode
|
仅适用于 standard3 SKU。 可以将此属性设置为最多允许 3 个高密度分区,允许最多 1000 个索引,这远远高于任何其他 SKU 允许的最大索引。 对于 standard3 SKU,该值为“default”或“highDensity”。 对于所有其他 SKU,此值必须为“default”。
|
|
properties.networkRuleSet
|
|
NetworkRuleSet
|
确定如何访问 Azure AI 搜索服务的网络特定规则。
|
|
properties.partitionCount
|
|
integer
(int32)
minimum: 1 maximum: 12
|
搜索服务中的分区数;如果指定,则它可以是 1、2、3、4、6 或 12。 大于 1 的值仅适用于标准 SKU。 对于 hostingMode 设置为“highDensity”的“standard3”服务,允许的值介于 1 到 3 之间。
|
|
properties.publicNetworkAccess
|
|
PublicNetworkAccess
|
此值可以设置为“已启用”,以避免对现有客户资源和模板进行重大更改。 如果设置为“disabled”,则不允许通过公共接口的流量,专用终结点连接将是独占访问方法。
|
|
properties.replicaCount
|
|
integer
(int32)
minimum: 1 maximum: 12
|
搜索服务中的副本数。 如果指定,它必须是标准 SKU 的 1 到 12(含 1 到 3)之间的值,对于基本 SKU,该值必须介于 1 和 3 之间。
|
|
properties.semanticSearch
|
|
SearchSemanticSearch
|
设置控制语义搜索可用性的选项。 此配置仅适用于特定位置的某些 Azure AI 搜索 SKU。
|
|
properties.upgradeAvailable
|
|
UpgradeAvailable
|
指示搜索服务是否有可用的升级。
|
|
sku
|
|
Sku
|
搜索服务的 SKU,用于确定价格层和容量限制。 创建新搜索服务时,此属性是必需的。
|
|
tags
|
|
object
|
资源标记。
|
响应
| 名称 |
类型 |
说明 |
|
200 OK
|
SearchService
|
已成功更新现有服务定义。 如果更改了副本或分区数,缩放操作将异步进行。 可以通过 Get Service 请求的响应中返回的 provisioningState 属性检查缩放作的状态。
|
|
201 Created
|
SearchService
|
如果请求创建免费搜索服务,则服务现已预配并可供使用,但存在 DNS 传播延迟。 对于其他 SKU 类型,预配以异步方式进行。 可以通过 Get Service 请求的响应中返回的 provisioningState 属性检查缩放作的状态。
|
|
Other Status Codes
|
CloudError
|
HTTP 400 (错误请求):给定的服务名称或服务定义无效。 有关详细信息,请参阅响应中的错误代码和消息。 HTTP 404(找不到):找不到订阅或资源组。 HTTP 409 (冲突):已禁用指定的订阅。
|
安全性
azure_auth
指定Microsoft标识平台上支持的隐式授权流。
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
| 名称 |
说明 |
|
user_impersonation
|
模拟用户帐户
|
示例
SearchCreateOrUpdateService
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice?api-version=2025-05-01
{
"location": "westus",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"hostingMode": "default",
"computeType": "default"
}
}
import com.azure.resourcemanager.search.fluent.models.SearchServiceInner;
import com.azure.resourcemanager.search.models.ComputeType;
import com.azure.resourcemanager.search.models.HostingMode;
import com.azure.resourcemanager.search.models.Sku;
import com.azure.resourcemanager.search.models.SkuName;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Services CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateService.
* json
*/
/**
* Sample code: SearchCreateOrUpdateService.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void searchCreateOrUpdateService(com.azure.resourcemanager.AzureResourceManager azure) {
azure.searchServices().manager().serviceClient().getServices().createOrUpdate("rg1", "mysearchservice",
new SearchServiceInner().withLocation("westus").withTags(mapOf("app-name", "My e-commerce app"))
.withSku(new Sku().withName(SkuName.STANDARD)).withReplicaCount(3).withPartitionCount(1)
.withHostingMode(HostingMode.DEFAULT).withComputeType(ComputeType.DEFAULT),
null, com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
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_create_or_update_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.services.begin_create_or_update(
resource_group_name="rg1",
search_service_name="mysearchservice",
service={
"location": "westus",
"properties": {"computeType": "default", "hostingMode": "default", "partitionCount": 1, "replicaCount": 3},
"sku": {"name": "standard"},
"tags": {"app-name": "My e-commerce app"},
},
).result()
print(response)
# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateService.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/azcore/to"
"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/fb3217991ff57b5760525aeba1a0670bfe0880fa/specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateService.json
func ExampleServicesClient_BeginCreateOrUpdate_searchCreateOrUpdateService() {
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)
}
poller, err := clientFactory.NewServicesClient().BeginCreateOrUpdate(ctx, "rg1", "mysearchservice", armsearch.Service{
Location: to.Ptr("westus"),
Tags: map[string]*string{
"app-name": to.Ptr("My e-commerce app"),
},
Properties: &armsearch.ServiceProperties{
ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
HostingMode: to.Ptr(armsearch.HostingModeDefault),
PartitionCount: to.Ptr[int32](1),
ReplicaCount: to.Ptr[int32](3),
},
SKU: &armsearch.SKU{
Name: to.Ptr(armsearch.SKUNameStandard),
},
}, &armsearch.SearchManagementRequestOptions{ClientRequestID: nil}, 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.Service = armsearch.Service{
// Name: to.Ptr("mysearchservice"),
// Type: to.Ptr("Microsoft.Search/searchServices"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice"),
// SystemData: &armsearch.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-01-01T00:00:00.000Z"); return t}()),
// CreatedBy: to.Ptr("My e-commerce app"),
// CreatedByType: to.Ptr(armsearch.CreatedByTypeApplication),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-01T00:00:00.000Z"); return t}()),
// LastModifiedBy: to.Ptr("fakeuser@contoso.com"),
// LastModifiedByType: to.Ptr(armsearch.CreatedByTypeUser),
// },
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "app-name": to.Ptr("My e-commerce app"),
// },
// Properties: &armsearch.ServiceProperties{
// AuthOptions: &armsearch.DataPlaneAuthOptions{
// APIKeyOnly: map[string]any{
// },
// },
// ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
// DataExfiltrationProtections: []*armsearch.SearchDataExfiltrationProtection{
// },
// DisableLocalAuth: to.Ptr(false),
// EncryptionWithCmk: &armsearch.EncryptionWithCmk{
// EncryptionComplianceStatus: to.Ptr(armsearch.SearchEncryptionComplianceStatusCompliant),
// Enforcement: to.Ptr(armsearch.SearchEncryptionWithCmkUnspecified),
// },
// Endpoint: to.Ptr("https://mysearchservice.search.windows.net/"),
// HostingMode: to.Ptr(armsearch.HostingModeDefault),
// NetworkRuleSet: &armsearch.NetworkRuleSet{
// Bypass: to.Ptr(armsearch.SearchBypassNone),
// IPRules: []*armsearch.IPRule{
// },
// },
// PartitionCount: to.Ptr[int32](1),
// PrivateEndpointConnections: []*armsearch.PrivateEndpointConnection{
// },
// ProvisioningState: to.Ptr(armsearch.ProvisioningStateSucceeded),
// PublicNetworkAccess: to.Ptr(armsearch.PublicNetworkAccessEnabled),
// ReplicaCount: to.Ptr[int32](3),
// SharedPrivateLinkResources: []*armsearch.SharedPrivateLinkResource{
// },
// Status: to.Ptr(armsearch.SearchServiceStatusProvisioning),
// StatusDetails: to.Ptr(""),
// UpgradeAvailable: to.Ptr(armsearch.UpgradeAvailableNotAvailable),
// },
// SKU: &armsearch.SKU{
// Name: to.Ptr(armsearch.SKUNameStandard),
// },
// }
}
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");
require("dotenv/config");
/**
* This sample demonstrates how to Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
*
* @summary Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateService.json
*/
async function searchCreateOrUpdateService() {
const subscriptionId = process.env["SEARCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["SEARCH_RESOURCE_GROUP"] || "rg1";
const searchServiceName = "mysearchservice";
const service = {
computeType: "default",
hostingMode: "default",
location: "westus",
partitionCount: 1,
replicaCount: 3,
sku: { name: "standard" },
tags: { appName: "My e-commerce app" },
};
const credential = new DefaultAzureCredential();
const client = new SearchManagementClient(credential, subscriptionId);
const result = await client.services.beginCreateOrUpdateAndWait(
resourceGroupName,
searchServiceName,
service,
);
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Search.Models;
using Azure.ResourceManager.Search;
// Generated from example definition: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateService.json
// this example is just showing the usage of "Services_CreateOrUpdate" 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://free.blessedness.top/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this SearchServiceResource
SearchServiceCollection collection = resourceGroupResource.GetSearchServices();
// invoke the operation
string searchServiceName = "mysearchservice";
SearchServiceData data = new SearchServiceData(new AzureLocation("westus"))
{
SearchSkuName = SearchServiceSkuName.Standard,
ReplicaCount = 3,
PartitionCount = 1,
HostingMode = SearchServiceHostingMode.Default,
ComputeType = SearchServiceComputeType.Default,
Tags =
{
["app-name"] = "My e-commerce app"
},
};
ArmOperation<SearchServiceResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data);
SearchServiceResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SearchServiceData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
SearchCreateOrUpdateServiceAuthOptions
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice?api-version=2025-05-01
{
"location": "westus",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"hostingMode": "default",
"computeType": "default",
"authOptions": {
"aadOrApiKey": {
"aadAuthFailureMode": "http401WithBearerChallenge"
}
}
}
}
import com.azure.resourcemanager.search.fluent.models.SearchServiceInner;
import com.azure.resourcemanager.search.models.AadAuthFailureMode;
import com.azure.resourcemanager.search.models.ComputeType;
import com.azure.resourcemanager.search.models.DataPlaneAadOrApiKeyAuthOption;
import com.azure.resourcemanager.search.models.DataPlaneAuthOptions;
import com.azure.resourcemanager.search.models.HostingMode;
import com.azure.resourcemanager.search.models.Sku;
import com.azure.resourcemanager.search.models.SkuName;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Services CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/
* SearchCreateOrUpdateServiceAuthOptions.json
*/
/**
* Sample code: SearchCreateOrUpdateServiceAuthOptions.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void searchCreateOrUpdateServiceAuthOptions(com.azure.resourcemanager.AzureResourceManager azure) {
azure.searchServices().manager().serviceClient().getServices().createOrUpdate("rg1", "mysearchservice",
new SearchServiceInner().withLocation("westus").withTags(mapOf("app-name", "My e-commerce app"))
.withSku(new Sku().withName(SkuName.STANDARD)).withReplicaCount(3).withPartitionCount(1)
.withHostingMode(HostingMode.DEFAULT).withComputeType(ComputeType.DEFAULT)
.withAuthOptions(new DataPlaneAuthOptions().withAadOrApiKey(new DataPlaneAadOrApiKeyAuthOption()
.withAadAuthFailureMode(AadAuthFailureMode.HTTP401WITH_BEARER_CHALLENGE))),
null, com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
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_create_or_update_service_auth_options.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.services.begin_create_or_update(
resource_group_name="rg1",
search_service_name="mysearchservice",
service={
"location": "westus",
"properties": {
"authOptions": {"aadOrApiKey": {"aadAuthFailureMode": "http401WithBearerChallenge"}},
"computeType": "default",
"hostingMode": "default",
"partitionCount": 1,
"replicaCount": 3,
},
"sku": {"name": "standard"},
"tags": {"app-name": "My e-commerce app"},
},
).result()
print(response)
# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceAuthOptions.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/azcore/to"
"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/fb3217991ff57b5760525aeba1a0670bfe0880fa/specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceAuthOptions.json
func ExampleServicesClient_BeginCreateOrUpdate_searchCreateOrUpdateServiceAuthOptions() {
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)
}
poller, err := clientFactory.NewServicesClient().BeginCreateOrUpdate(ctx, "rg1", "mysearchservice", armsearch.Service{
Location: to.Ptr("westus"),
Tags: map[string]*string{
"app-name": to.Ptr("My e-commerce app"),
},
Properties: &armsearch.ServiceProperties{
AuthOptions: &armsearch.DataPlaneAuthOptions{
AADOrAPIKey: &armsearch.DataPlaneAADOrAPIKeyAuthOption{
AADAuthFailureMode: to.Ptr(armsearch.AADAuthFailureModeHttp401WithBearerChallenge),
},
},
ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
HostingMode: to.Ptr(armsearch.HostingModeDefault),
PartitionCount: to.Ptr[int32](1),
ReplicaCount: to.Ptr[int32](3),
},
SKU: &armsearch.SKU{
Name: to.Ptr(armsearch.SKUNameStandard),
},
}, &armsearch.SearchManagementRequestOptions{ClientRequestID: nil}, 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.Service = armsearch.Service{
// Name: to.Ptr("mysearchservice"),
// Type: to.Ptr("Microsoft.Search/searchServices"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice"),
// SystemData: &armsearch.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-01-01T00:00:00.000Z"); return t}()),
// CreatedBy: to.Ptr("My e-commerce app"),
// CreatedByType: to.Ptr(armsearch.CreatedByTypeApplication),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-01T00:00:00.000Z"); return t}()),
// LastModifiedBy: to.Ptr("fakeuser@contoso.com"),
// LastModifiedByType: to.Ptr(armsearch.CreatedByTypeUser),
// },
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "app-name": to.Ptr("My e-commerce app"),
// },
// Properties: &armsearch.ServiceProperties{
// AuthOptions: &armsearch.DataPlaneAuthOptions{
// AADOrAPIKey: &armsearch.DataPlaneAADOrAPIKeyAuthOption{
// AADAuthFailureMode: to.Ptr(armsearch.AADAuthFailureModeHttp401WithBearerChallenge),
// },
// },
// ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
// DataExfiltrationProtections: []*armsearch.SearchDataExfiltrationProtection{
// },
// EncryptionWithCmk: &armsearch.EncryptionWithCmk{
// EncryptionComplianceStatus: to.Ptr(armsearch.SearchEncryptionComplianceStatusCompliant),
// Enforcement: to.Ptr(armsearch.SearchEncryptionWithCmkUnspecified),
// },
// Endpoint: to.Ptr("https://mysearchservice.search.windows.net/"),
// HostingMode: to.Ptr(armsearch.HostingModeDefault),
// NetworkRuleSet: &armsearch.NetworkRuleSet{
// Bypass: to.Ptr(armsearch.SearchBypassNone),
// IPRules: []*armsearch.IPRule{
// },
// },
// PartitionCount: to.Ptr[int32](1),
// PrivateEndpointConnections: []*armsearch.PrivateEndpointConnection{
// },
// ProvisioningState: to.Ptr(armsearch.ProvisioningStateSucceeded),
// PublicNetworkAccess: to.Ptr(armsearch.PublicNetworkAccessEnabled),
// ReplicaCount: to.Ptr[int32](3),
// SharedPrivateLinkResources: []*armsearch.SharedPrivateLinkResource{
// },
// Status: to.Ptr(armsearch.SearchServiceStatusProvisioning),
// StatusDetails: to.Ptr(""),
// UpgradeAvailable: to.Ptr(armsearch.UpgradeAvailableNotAvailable),
// },
// SKU: &armsearch.SKU{
// Name: to.Ptr(armsearch.SKUNameStandard),
// },
// }
}
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");
require("dotenv/config");
/**
* This sample demonstrates how to Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
*
* @summary Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceAuthOptions.json
*/
async function searchCreateOrUpdateServiceAuthOptions() {
const subscriptionId = process.env["SEARCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["SEARCH_RESOURCE_GROUP"] || "rg1";
const searchServiceName = "mysearchservice";
const service = {
authOptions: {
aadOrApiKey: { aadAuthFailureMode: "http401WithBearerChallenge" },
},
computeType: "default",
hostingMode: "default",
location: "westus",
partitionCount: 1,
replicaCount: 3,
sku: { name: "standard" },
tags: { appName: "My e-commerce app" },
};
const credential = new DefaultAzureCredential();
const client = new SearchManagementClient(credential, subscriptionId);
const result = await client.services.beginCreateOrUpdateAndWait(
resourceGroupName,
searchServiceName,
service,
);
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Search.Models;
using Azure.ResourceManager.Search;
// Generated from example definition: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceAuthOptions.json
// this example is just showing the usage of "Services_CreateOrUpdate" 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://free.blessedness.top/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this SearchServiceResource
SearchServiceCollection collection = resourceGroupResource.GetSearchServices();
// invoke the operation
string searchServiceName = "mysearchservice";
SearchServiceData data = new SearchServiceData(new AzureLocation("westus"))
{
SearchSkuName = SearchServiceSkuName.Standard,
ReplicaCount = 3,
PartitionCount = 1,
HostingMode = SearchServiceHostingMode.Default,
ComputeType = SearchServiceComputeType.Default,
AuthOptions = new SearchAadAuthDataPlaneAuthOptions
{
AadAuthFailureMode = SearchAadAuthFailureMode.Http401WithBearerChallenge,
},
Tags =
{
["app-name"] = "My e-commerce app"
},
};
ArmOperation<SearchServiceResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data);
SearchServiceResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SearchServiceData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"authOptions": {
"aadOrApiKey": {
"aadAuthFailureMode": "http401WithBearerChallenge"
}
},
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"authOptions": {
"aadOrApiKey": {
"aadAuthFailureMode": "http401WithBearerChallenge"
}
},
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
SearchCreateOrUpdateServiceDisableLocalAuth
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice?api-version=2025-05-01
{
"location": "westus",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"hostingMode": "default",
"computeType": "default",
"disableLocalAuth": true
}
}
import com.azure.resourcemanager.search.fluent.models.SearchServiceInner;
import com.azure.resourcemanager.search.models.ComputeType;
import com.azure.resourcemanager.search.models.HostingMode;
import com.azure.resourcemanager.search.models.Sku;
import com.azure.resourcemanager.search.models.SkuName;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Services CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/
* SearchCreateOrUpdateServiceDisableLocalAuth.json
*/
/**
* Sample code: SearchCreateOrUpdateServiceDisableLocalAuth.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
searchCreateOrUpdateServiceDisableLocalAuth(com.azure.resourcemanager.AzureResourceManager azure) {
azure.searchServices().manager().serviceClient().getServices().createOrUpdate("rg1", "mysearchservice",
new SearchServiceInner().withLocation("westus").withTags(mapOf("app-name", "My e-commerce app"))
.withSku(new Sku().withName(SkuName.STANDARD)).withReplicaCount(3).withPartitionCount(1)
.withHostingMode(HostingMode.DEFAULT).withComputeType(ComputeType.DEFAULT).withDisableLocalAuth(true),
null, com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
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_create_or_update_service_disable_local_auth.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.services.begin_create_or_update(
resource_group_name="rg1",
search_service_name="mysearchservice",
service={
"location": "westus",
"properties": {
"computeType": "default",
"disableLocalAuth": True,
"hostingMode": "default",
"partitionCount": 1,
"replicaCount": 3,
},
"sku": {"name": "standard"},
"tags": {"app-name": "My e-commerce app"},
},
).result()
print(response)
# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceDisableLocalAuth.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/azcore/to"
"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/fb3217991ff57b5760525aeba1a0670bfe0880fa/specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceDisableLocalAuth.json
func ExampleServicesClient_BeginCreateOrUpdate_searchCreateOrUpdateServiceDisableLocalAuth() {
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)
}
poller, err := clientFactory.NewServicesClient().BeginCreateOrUpdate(ctx, "rg1", "mysearchservice", armsearch.Service{
Location: to.Ptr("westus"),
Tags: map[string]*string{
"app-name": to.Ptr("My e-commerce app"),
},
Properties: &armsearch.ServiceProperties{
ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
DisableLocalAuth: to.Ptr(true),
HostingMode: to.Ptr(armsearch.HostingModeDefault),
PartitionCount: to.Ptr[int32](1),
ReplicaCount: to.Ptr[int32](3),
},
SKU: &armsearch.SKU{
Name: to.Ptr(armsearch.SKUNameStandard),
},
}, &armsearch.SearchManagementRequestOptions{ClientRequestID: nil}, 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.Service = armsearch.Service{
// Name: to.Ptr("mysearchservice"),
// Type: to.Ptr("Microsoft.Search/searchServices"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice"),
// SystemData: &armsearch.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-01-01T00:00:00.000Z"); return t}()),
// CreatedBy: to.Ptr("My e-commerce app"),
// CreatedByType: to.Ptr(armsearch.CreatedByTypeApplication),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-01T00:00:00.000Z"); return t}()),
// LastModifiedBy: to.Ptr("fakeuser@contoso.com"),
// LastModifiedByType: to.Ptr(armsearch.CreatedByTypeUser),
// },
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "app-name": to.Ptr("My e-commerce app"),
// },
// Properties: &armsearch.ServiceProperties{
// ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
// DataExfiltrationProtections: []*armsearch.SearchDataExfiltrationProtection{
// },
// DisableLocalAuth: to.Ptr(true),
// EncryptionWithCmk: &armsearch.EncryptionWithCmk{
// EncryptionComplianceStatus: to.Ptr(armsearch.SearchEncryptionComplianceStatusCompliant),
// Enforcement: to.Ptr(armsearch.SearchEncryptionWithCmkUnspecified),
// },
// Endpoint: to.Ptr("https://mysearchservice.search.windows.net/"),
// HostingMode: to.Ptr(armsearch.HostingModeDefault),
// NetworkRuleSet: &armsearch.NetworkRuleSet{
// Bypass: to.Ptr(armsearch.SearchBypassNone),
// IPRules: []*armsearch.IPRule{
// },
// },
// PartitionCount: to.Ptr[int32](1),
// PrivateEndpointConnections: []*armsearch.PrivateEndpointConnection{
// },
// ProvisioningState: to.Ptr(armsearch.ProvisioningStateSucceeded),
// PublicNetworkAccess: to.Ptr(armsearch.PublicNetworkAccessEnabled),
// ReplicaCount: to.Ptr[int32](3),
// SharedPrivateLinkResources: []*armsearch.SharedPrivateLinkResource{
// },
// Status: to.Ptr(armsearch.SearchServiceStatusProvisioning),
// StatusDetails: to.Ptr(""),
// UpgradeAvailable: to.Ptr(armsearch.UpgradeAvailableNotAvailable),
// },
// SKU: &armsearch.SKU{
// Name: to.Ptr(armsearch.SKUNameStandard),
// },
// }
}
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");
require("dotenv/config");
/**
* This sample demonstrates how to Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
*
* @summary Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceDisableLocalAuth.json
*/
async function searchCreateOrUpdateServiceDisableLocalAuth() {
const subscriptionId = process.env["SEARCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["SEARCH_RESOURCE_GROUP"] || "rg1";
const searchServiceName = "mysearchservice";
const service = {
computeType: "default",
disableLocalAuth: true,
hostingMode: "default",
location: "westus",
partitionCount: 1,
replicaCount: 3,
sku: { name: "standard" },
tags: { appName: "My e-commerce app" },
};
const credential = new DefaultAzureCredential();
const client = new SearchManagementClient(credential, subscriptionId);
const result = await client.services.beginCreateOrUpdateAndWait(
resourceGroupName,
searchServiceName,
service,
);
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Search.Models;
using Azure.ResourceManager.Search;
// Generated from example definition: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceDisableLocalAuth.json
// this example is just showing the usage of "Services_CreateOrUpdate" 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://free.blessedness.top/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this SearchServiceResource
SearchServiceCollection collection = resourceGroupResource.GetSearchServices();
// invoke the operation
string searchServiceName = "mysearchservice";
SearchServiceData data = new SearchServiceData(new AzureLocation("westus"))
{
SearchSkuName = SearchServiceSkuName.Standard,
ReplicaCount = 3,
PartitionCount = 1,
HostingMode = SearchServiceHostingMode.Default,
ComputeType = SearchServiceComputeType.Default,
IsLocalAuthDisabled = true,
Tags =
{
["app-name"] = "My e-commerce app"
},
};
ArmOperation<SearchServiceResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data);
SearchServiceResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SearchServiceData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": true,
"authOptions": null,
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": true,
"authOptions": null,
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
SearchCreateOrUpdateServiceToAllowAccessFromPrivateEndpoints
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice?api-version=2025-05-01
{
"location": "westus",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"publicNetworkAccess": "disabled",
"hostingMode": "default",
"computeType": "default"
}
}
import com.azure.resourcemanager.search.fluent.models.SearchServiceInner;
import com.azure.resourcemanager.search.models.ComputeType;
import com.azure.resourcemanager.search.models.HostingMode;
import com.azure.resourcemanager.search.models.PublicNetworkAccess;
import com.azure.resourcemanager.search.models.Sku;
import com.azure.resourcemanager.search.models.SkuName;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Services CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/
* SearchCreateOrUpdateServiceToAllowAccessFromPrivateEndpoints.json
*/
/**
* Sample code: SearchCreateOrUpdateServiceToAllowAccessFromPrivateEndpoints.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void searchCreateOrUpdateServiceToAllowAccessFromPrivateEndpoints(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.searchServices().manager().serviceClient().getServices().createOrUpdate("rg1", "mysearchservice",
new SearchServiceInner().withLocation("westus").withTags(mapOf("app-name", "My e-commerce app"))
.withSku(new Sku().withName(SkuName.STANDARD)).withReplicaCount(3).withPartitionCount(1)
.withHostingMode(HostingMode.DEFAULT).withComputeType(ComputeType.DEFAULT)
.withPublicNetworkAccess(PublicNetworkAccess.DISABLED),
null, com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
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_create_or_update_service_to_allow_access_from_private_endpoints.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.services.begin_create_or_update(
resource_group_name="rg1",
search_service_name="mysearchservice",
service={
"location": "westus",
"properties": {
"computeType": "default",
"hostingMode": "default",
"partitionCount": 1,
"publicNetworkAccess": "disabled",
"replicaCount": 3,
},
"sku": {"name": "standard"},
"tags": {"app-name": "My e-commerce app"},
},
).result()
print(response)
# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPrivateEndpoints.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/azcore/to"
"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/fb3217991ff57b5760525aeba1a0670bfe0880fa/specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPrivateEndpoints.json
func ExampleServicesClient_BeginCreateOrUpdate_searchCreateOrUpdateServiceToAllowAccessFromPrivateEndpoints() {
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)
}
poller, err := clientFactory.NewServicesClient().BeginCreateOrUpdate(ctx, "rg1", "mysearchservice", armsearch.Service{
Location: to.Ptr("westus"),
Tags: map[string]*string{
"app-name": to.Ptr("My e-commerce app"),
},
Properties: &armsearch.ServiceProperties{
ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
HostingMode: to.Ptr(armsearch.HostingModeDefault),
PartitionCount: to.Ptr[int32](1),
PublicNetworkAccess: to.Ptr(armsearch.PublicNetworkAccessDisabled),
ReplicaCount: to.Ptr[int32](3),
},
SKU: &armsearch.SKU{
Name: to.Ptr(armsearch.SKUNameStandard),
},
}, &armsearch.SearchManagementRequestOptions{ClientRequestID: nil}, 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.Service = armsearch.Service{
// Name: to.Ptr("mysearchservice"),
// Type: to.Ptr("Microsoft.Search/searchServices"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice"),
// SystemData: &armsearch.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-01-01T00:00:00.000Z"); return t}()),
// CreatedBy: to.Ptr("My e-commerce app"),
// CreatedByType: to.Ptr(armsearch.CreatedByTypeApplication),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-01T00:00:00.000Z"); return t}()),
// LastModifiedBy: to.Ptr("fakeuser@contoso.com"),
// LastModifiedByType: to.Ptr(armsearch.CreatedByTypeUser),
// },
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "app-name": to.Ptr("My e-commerce app"),
// },
// Properties: &armsearch.ServiceProperties{
// AuthOptions: &armsearch.DataPlaneAuthOptions{
// APIKeyOnly: map[string]any{
// },
// },
// ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
// DataExfiltrationProtections: []*armsearch.SearchDataExfiltrationProtection{
// },
// DisableLocalAuth: to.Ptr(false),
// EncryptionWithCmk: &armsearch.EncryptionWithCmk{
// EncryptionComplianceStatus: to.Ptr(armsearch.SearchEncryptionComplianceStatusCompliant),
// Enforcement: to.Ptr(armsearch.SearchEncryptionWithCmkUnspecified),
// },
// Endpoint: to.Ptr("https://mysearchservice.search.windows.net/"),
// HostingMode: to.Ptr(armsearch.HostingModeDefault),
// NetworkRuleSet: &armsearch.NetworkRuleSet{
// Bypass: to.Ptr(armsearch.SearchBypassNone),
// IPRules: []*armsearch.IPRule{
// },
// },
// PartitionCount: to.Ptr[int32](1),
// PrivateEndpointConnections: []*armsearch.PrivateEndpointConnection{
// },
// ProvisioningState: to.Ptr(armsearch.ProvisioningStateSucceeded),
// PublicNetworkAccess: to.Ptr(armsearch.PublicNetworkAccessDisabled),
// ReplicaCount: to.Ptr[int32](3),
// SharedPrivateLinkResources: []*armsearch.SharedPrivateLinkResource{
// },
// Status: to.Ptr(armsearch.SearchServiceStatusProvisioning),
// StatusDetails: to.Ptr(""),
// UpgradeAvailable: to.Ptr(armsearch.UpgradeAvailableNotAvailable),
// },
// SKU: &armsearch.SKU{
// Name: to.Ptr(armsearch.SKUNameStandard),
// },
// }
}
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");
require("dotenv/config");
/**
* This sample demonstrates how to Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
*
* @summary Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPrivateEndpoints.json
*/
async function searchCreateOrUpdateServiceToAllowAccessFromPrivateEndpoints() {
const subscriptionId = process.env["SEARCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["SEARCH_RESOURCE_GROUP"] || "rg1";
const searchServiceName = "mysearchservice";
const service = {
computeType: "default",
hostingMode: "default",
location: "westus",
partitionCount: 1,
publicNetworkAccess: "disabled",
replicaCount: 3,
sku: { name: "standard" },
tags: { appName: "My e-commerce app" },
};
const credential = new DefaultAzureCredential();
const client = new SearchManagementClient(credential, subscriptionId);
const result = await client.services.beginCreateOrUpdateAndWait(
resourceGroupName,
searchServiceName,
service,
);
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Search.Models;
using Azure.ResourceManager.Search;
// Generated from example definition: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPrivateEndpoints.json
// this example is just showing the usage of "Services_CreateOrUpdate" 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://free.blessedness.top/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this SearchServiceResource
SearchServiceCollection collection = resourceGroupResource.GetSearchServices();
// invoke the operation
string searchServiceName = "mysearchservice";
SearchServiceData data = new SearchServiceData(new AzureLocation("westus"))
{
SearchSkuName = SearchServiceSkuName.Standard,
ReplicaCount = 3,
PartitionCount = 1,
HostingMode = SearchServiceHostingMode.Default,
ComputeType = SearchServiceComputeType.Default,
PublicInternetAccess = SearchServicePublicInternetAccess.Disabled,
Tags =
{
["app-name"] = "My e-commerce app"
},
};
ArmOperation<SearchServiceResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data);
SearchServiceResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SearchServiceData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "disabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "disabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPs
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice?api-version=2025-05-01
{
"location": "westus",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 1,
"partitionCount": 1,
"networkRuleSet": {
"ipRules": [
{
"value": "123.4.5.6"
},
{
"value": "123.4.6.0/18"
}
]
},
"hostingMode": "default",
"computeType": "default"
}
}
import com.azure.resourcemanager.search.fluent.models.SearchServiceInner;
import com.azure.resourcemanager.search.models.ComputeType;
import com.azure.resourcemanager.search.models.HostingMode;
import com.azure.resourcemanager.search.models.IpRule;
import com.azure.resourcemanager.search.models.NetworkRuleSet;
import com.azure.resourcemanager.search.models.Sku;
import com.azure.resourcemanager.search.models.SkuName;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Services CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/
* SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPs.json
*/
/**
* Sample code: SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPs.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void searchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPs(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.searchServices().manager().serviceClient().getServices().createOrUpdate("rg1", "mysearchservice",
new SearchServiceInner().withLocation("westus").withTags(mapOf("app-name", "My e-commerce app"))
.withSku(new Sku().withName(SkuName.STANDARD)).withReplicaCount(1).withPartitionCount(1)
.withHostingMode(HostingMode.DEFAULT).withComputeType(ComputeType.DEFAULT)
.withNetworkRuleSet(new NetworkRuleSet().withIpRules(
Arrays.asList(new IpRule().withValue("123.4.5.6"), new IpRule().withValue("123.4.6.0/18")))),
null, com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
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_create_or_update_service_to_allow_access_from_public_custom_ips.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.services.begin_create_or_update(
resource_group_name="rg1",
search_service_name="mysearchservice",
service={
"location": "westus",
"properties": {
"computeType": "default",
"hostingMode": "default",
"networkRuleSet": {"ipRules": [{"value": "123.4.5.6"}, {"value": "123.4.6.0/18"}]},
"partitionCount": 1,
"replicaCount": 1,
},
"sku": {"name": "standard"},
"tags": {"app-name": "My e-commerce app"},
},
).result()
print(response)
# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPs.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/azcore/to"
"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/fb3217991ff57b5760525aeba1a0670bfe0880fa/specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPs.json
func ExampleServicesClient_BeginCreateOrUpdate_searchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPs() {
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)
}
poller, err := clientFactory.NewServicesClient().BeginCreateOrUpdate(ctx, "rg1", "mysearchservice", armsearch.Service{
Location: to.Ptr("westus"),
Tags: map[string]*string{
"app-name": to.Ptr("My e-commerce app"),
},
Properties: &armsearch.ServiceProperties{
ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
HostingMode: to.Ptr(armsearch.HostingModeDefault),
NetworkRuleSet: &armsearch.NetworkRuleSet{
IPRules: []*armsearch.IPRule{
{
Value: to.Ptr("123.4.5.6"),
},
{
Value: to.Ptr("123.4.6.0/18"),
}},
},
PartitionCount: to.Ptr[int32](1),
ReplicaCount: to.Ptr[int32](1),
},
SKU: &armsearch.SKU{
Name: to.Ptr(armsearch.SKUNameStandard),
},
}, &armsearch.SearchManagementRequestOptions{ClientRequestID: nil}, 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.Service = armsearch.Service{
// Name: to.Ptr("mysearchservice"),
// Type: to.Ptr("Microsoft.Search/searchServices"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice"),
// SystemData: &armsearch.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-01-01T00:00:00.000Z"); return t}()),
// CreatedBy: to.Ptr("My e-commerce app"),
// CreatedByType: to.Ptr(armsearch.CreatedByTypeApplication),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-01T00:00:00.000Z"); return t}()),
// LastModifiedBy: to.Ptr("fakeuser@contoso.com"),
// LastModifiedByType: to.Ptr(armsearch.CreatedByTypeUser),
// },
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "app-name": to.Ptr("My e-commerce app"),
// },
// Properties: &armsearch.ServiceProperties{
// AuthOptions: &armsearch.DataPlaneAuthOptions{
// APIKeyOnly: map[string]any{
// },
// },
// ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
// DataExfiltrationProtections: []*armsearch.SearchDataExfiltrationProtection{
// },
// DisableLocalAuth: to.Ptr(false),
// EncryptionWithCmk: &armsearch.EncryptionWithCmk{
// EncryptionComplianceStatus: to.Ptr(armsearch.SearchEncryptionComplianceStatusCompliant),
// Enforcement: to.Ptr(armsearch.SearchEncryptionWithCmkUnspecified),
// },
// Endpoint: to.Ptr("https://mysearchservice.search.windows.net/"),
// HostingMode: to.Ptr(armsearch.HostingModeDefault),
// NetworkRuleSet: &armsearch.NetworkRuleSet{
// IPRules: []*armsearch.IPRule{
// {
// Value: to.Ptr("123.4.5.6"),
// },
// {
// Value: to.Ptr("123.4.6.0/18"),
// }},
// },
// PartitionCount: to.Ptr[int32](1),
// PrivateEndpointConnections: []*armsearch.PrivateEndpointConnection{
// },
// ProvisioningState: to.Ptr(armsearch.ProvisioningStateSucceeded),
// PublicNetworkAccess: to.Ptr(armsearch.PublicNetworkAccessEnabled),
// ReplicaCount: to.Ptr[int32](1),
// SharedPrivateLinkResources: []*armsearch.SharedPrivateLinkResource{
// },
// Status: to.Ptr(armsearch.SearchServiceStatusProvisioning),
// StatusDetails: to.Ptr(""),
// UpgradeAvailable: to.Ptr(armsearch.UpgradeAvailableNotAvailable),
// },
// SKU: &armsearch.SKU{
// Name: to.Ptr(armsearch.SKUNameStandard),
// },
// }
}
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");
require("dotenv/config");
/**
* This sample demonstrates how to Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
*
* @summary Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPs.json
*/
async function searchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPs() {
const subscriptionId = process.env["SEARCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["SEARCH_RESOURCE_GROUP"] || "rg1";
const searchServiceName = "mysearchservice";
const service = {
computeType: "default",
hostingMode: "default",
location: "westus",
networkRuleSet: {
ipRules: [{ value: "123.4.5.6" }, { value: "123.4.6.0/18" }],
},
partitionCount: 1,
replicaCount: 1,
sku: { name: "standard" },
tags: { appName: "My e-commerce app" },
};
const credential = new DefaultAzureCredential();
const client = new SearchManagementClient(credential, subscriptionId);
const result = await client.services.beginCreateOrUpdateAndWait(
resourceGroupName,
searchServiceName,
service,
);
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Search.Models;
using Azure.ResourceManager.Search;
// Generated from example definition: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPs.json
// this example is just showing the usage of "Services_CreateOrUpdate" 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://free.blessedness.top/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this SearchServiceResource
SearchServiceCollection collection = resourceGroupResource.GetSearchServices();
// invoke the operation
string searchServiceName = "mysearchservice";
SearchServiceData data = new SearchServiceData(new AzureLocation("westus"))
{
SearchSkuName = SearchServiceSkuName.Standard,
ReplicaCount = 1,
PartitionCount = 1,
HostingMode = SearchServiceHostingMode.Default,
ComputeType = SearchServiceComputeType.Default,
NetworkRuleSet = new SearchServiceNetworkRuleSet
{
IPRules = {new SearchServiceIPRule
{
Value = "123.4.5.6",
}, new SearchServiceIPRule
{
Value = "123.4.6.0/18",
}},
},
Tags =
{
["app-name"] = "My e-commerce app"
},
};
ArmOperation<SearchServiceResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data);
SearchServiceResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SearchServiceData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 1,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [
{
"value": "123.4.5.6"
},
{
"value": "123.4.6.0/18"
}
]
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 1,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [
{
"value": "123.4.5.6"
},
{
"value": "123.4.6.0/18"
}
]
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPsAndBypass
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice?api-version=2025-05-01
{
"location": "westus",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 1,
"partitionCount": 1,
"networkRuleSet": {
"ipRules": [
{
"value": "123.4.5.6"
},
{
"value": "123.4.6.0/18"
}
],
"bypass": "AzureServices"
},
"hostingMode": "default",
"computeType": "default"
}
}
import com.azure.resourcemanager.search.fluent.models.SearchServiceInner;
import com.azure.resourcemanager.search.models.ComputeType;
import com.azure.resourcemanager.search.models.HostingMode;
import com.azure.resourcemanager.search.models.IpRule;
import com.azure.resourcemanager.search.models.NetworkRuleSet;
import com.azure.resourcemanager.search.models.SearchBypass;
import com.azure.resourcemanager.search.models.Sku;
import com.azure.resourcemanager.search.models.SkuName;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Services CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/
* SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPsAndBypass.json
*/
/**
* Sample code: SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPsAndBypass.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void searchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPsAndBypass(
com.azure.resourcemanager.AzureResourceManager azure) {
azure.searchServices().manager().serviceClient().getServices().createOrUpdate("rg1", "mysearchservice",
new SearchServiceInner().withLocation("westus").withTags(mapOf("app-name", "My e-commerce app"))
.withSku(new Sku().withName(SkuName.STANDARD)).withReplicaCount(1).withPartitionCount(1)
.withHostingMode(HostingMode.DEFAULT).withComputeType(ComputeType.DEFAULT)
.withNetworkRuleSet(new NetworkRuleSet()
.withIpRules(
Arrays.asList(new IpRule().withValue("123.4.5.6"), new IpRule().withValue("123.4.6.0/18")))
.withBypass(SearchBypass.AZURE_SERVICES)),
null, com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
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_create_or_update_service_to_allow_access_from_public_custom_ips_and_bypass.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.services.begin_create_or_update(
resource_group_name="rg1",
search_service_name="mysearchservice",
service={
"location": "westus",
"properties": {
"computeType": "default",
"hostingMode": "default",
"networkRuleSet": {
"bypass": "AzureServices",
"ipRules": [{"value": "123.4.5.6"}, {"value": "123.4.6.0/18"}],
},
"partitionCount": 1,
"replicaCount": 1,
},
"sku": {"name": "standard"},
"tags": {"app-name": "My e-commerce app"},
},
).result()
print(response)
# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPsAndBypass.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/azcore/to"
"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/fb3217991ff57b5760525aeba1a0670bfe0880fa/specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPsAndBypass.json
func ExampleServicesClient_BeginCreateOrUpdate_searchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPsAndBypass() {
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)
}
poller, err := clientFactory.NewServicesClient().BeginCreateOrUpdate(ctx, "rg1", "mysearchservice", armsearch.Service{
Location: to.Ptr("westus"),
Tags: map[string]*string{
"app-name": to.Ptr("My e-commerce app"),
},
Properties: &armsearch.ServiceProperties{
ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
HostingMode: to.Ptr(armsearch.HostingModeDefault),
NetworkRuleSet: &armsearch.NetworkRuleSet{
Bypass: to.Ptr(armsearch.SearchBypassAzureServices),
IPRules: []*armsearch.IPRule{
{
Value: to.Ptr("123.4.5.6"),
},
{
Value: to.Ptr("123.4.6.0/18"),
}},
},
PartitionCount: to.Ptr[int32](1),
ReplicaCount: to.Ptr[int32](1),
},
SKU: &armsearch.SKU{
Name: to.Ptr(armsearch.SKUNameStandard),
},
}, &armsearch.SearchManagementRequestOptions{ClientRequestID: nil}, 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.Service = armsearch.Service{
// Name: to.Ptr("mysearchservice"),
// Type: to.Ptr("Microsoft.Search/searchServices"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice"),
// SystemData: &armsearch.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-01-01T00:00:00.000Z"); return t}()),
// CreatedBy: to.Ptr("My e-commerce app"),
// CreatedByType: to.Ptr(armsearch.CreatedByTypeApplication),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-01T00:00:00.000Z"); return t}()),
// LastModifiedBy: to.Ptr("fakeuser@contoso.com"),
// LastModifiedByType: to.Ptr(armsearch.CreatedByTypeUser),
// },
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "app-name": to.Ptr("My e-commerce app"),
// },
// Properties: &armsearch.ServiceProperties{
// AuthOptions: &armsearch.DataPlaneAuthOptions{
// APIKeyOnly: map[string]any{
// },
// },
// ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
// DataExfiltrationProtections: []*armsearch.SearchDataExfiltrationProtection{
// },
// DisableLocalAuth: to.Ptr(false),
// EncryptionWithCmk: &armsearch.EncryptionWithCmk{
// EncryptionComplianceStatus: to.Ptr(armsearch.SearchEncryptionComplianceStatusCompliant),
// Enforcement: to.Ptr(armsearch.SearchEncryptionWithCmkUnspecified),
// },
// Endpoint: to.Ptr("https://mysearchservice.search.windows.net/"),
// HostingMode: to.Ptr(armsearch.HostingModeDefault),
// NetworkRuleSet: &armsearch.NetworkRuleSet{
// Bypass: to.Ptr(armsearch.SearchBypassAzureServices),
// IPRules: []*armsearch.IPRule{
// {
// Value: to.Ptr("123.4.5.6"),
// },
// {
// Value: to.Ptr("123.4.6.0/18"),
// }},
// },
// PartitionCount: to.Ptr[int32](1),
// PrivateEndpointConnections: []*armsearch.PrivateEndpointConnection{
// },
// ProvisioningState: to.Ptr(armsearch.ProvisioningStateSucceeded),
// PublicNetworkAccess: to.Ptr(armsearch.PublicNetworkAccessEnabled),
// ReplicaCount: to.Ptr[int32](1),
// SharedPrivateLinkResources: []*armsearch.SharedPrivateLinkResource{
// },
// Status: to.Ptr(armsearch.SearchServiceStatusProvisioning),
// StatusDetails: to.Ptr(""),
// UpgradeAvailable: to.Ptr(armsearch.UpgradeAvailableNotAvailable),
// },
// SKU: &armsearch.SKU{
// Name: to.Ptr(armsearch.SKUNameStandard),
// },
// }
}
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");
require("dotenv/config");
/**
* This sample demonstrates how to Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
*
* @summary Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPsAndBypass.json
*/
async function searchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPsAndBypass() {
const subscriptionId = process.env["SEARCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["SEARCH_RESOURCE_GROUP"] || "rg1";
const searchServiceName = "mysearchservice";
const service = {
computeType: "default",
hostingMode: "default",
location: "westus",
networkRuleSet: {
bypass: "AzureServices",
ipRules: [{ value: "123.4.5.6" }, { value: "123.4.6.0/18" }],
},
partitionCount: 1,
replicaCount: 1,
sku: { name: "standard" },
tags: { appName: "My e-commerce app" },
};
const credential = new DefaultAzureCredential();
const client = new SearchManagementClient(credential, subscriptionId);
const result = await client.services.beginCreateOrUpdateAndWait(
resourceGroupName,
searchServiceName,
service,
);
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Search.Models;
using Azure.ResourceManager.Search;
// Generated from example definition: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceToAllowAccessFromPublicCustomIPsAndBypass.json
// this example is just showing the usage of "Services_CreateOrUpdate" 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://free.blessedness.top/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this SearchServiceResource
SearchServiceCollection collection = resourceGroupResource.GetSearchServices();
// invoke the operation
string searchServiceName = "mysearchservice";
SearchServiceData data = new SearchServiceData(new AzureLocation("westus"))
{
SearchSkuName = SearchServiceSkuName.Standard,
ReplicaCount = 1,
PartitionCount = 1,
HostingMode = SearchServiceHostingMode.Default,
ComputeType = SearchServiceComputeType.Default,
NetworkRuleSet = new SearchServiceNetworkRuleSet
{
IPRules = {new SearchServiceIPRule
{
Value = "123.4.5.6",
}, new SearchServiceIPRule
{
Value = "123.4.6.0/18",
}},
Bypass = SearchBypass.AzureServices,
},
Tags =
{
["app-name"] = "My e-commerce app"
},
};
ArmOperation<SearchServiceResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data);
SearchServiceResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SearchServiceData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 1,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [
{
"value": "123.4.5.6"
},
{
"value": "123.4.6.0/18"
}
],
"bypass": "AzureServices"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 1,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [
{
"value": "123.4.5.6"
},
{
"value": "123.4.6.0/18"
}
],
"bypass": "AzureServices"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
SearchCreateOrUpdateServiceWithCmkEnforcement
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice?api-version=2025-05-01
{
"location": "westus",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"hostingMode": "default",
"computeType": "default",
"encryptionWithCmk": {
"enforcement": "Enabled"
}
}
}
import com.azure.resourcemanager.search.fluent.models.SearchServiceInner;
import com.azure.resourcemanager.search.models.ComputeType;
import com.azure.resourcemanager.search.models.EncryptionWithCmk;
import com.azure.resourcemanager.search.models.HostingMode;
import com.azure.resourcemanager.search.models.SearchEncryptionWithCmk;
import com.azure.resourcemanager.search.models.Sku;
import com.azure.resourcemanager.search.models.SkuName;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Services CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/
* SearchCreateOrUpdateServiceWithCmkEnforcement.json
*/
/**
* Sample code: SearchCreateOrUpdateServiceWithCmkEnforcement.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
searchCreateOrUpdateServiceWithCmkEnforcement(com.azure.resourcemanager.AzureResourceManager azure) {
azure.searchServices().manager().serviceClient().getServices().createOrUpdate("rg1", "mysearchservice",
new SearchServiceInner().withLocation("westus").withTags(mapOf("app-name", "My e-commerce app"))
.withSku(new Sku().withName(SkuName.STANDARD)).withReplicaCount(3).withPartitionCount(1)
.withHostingMode(HostingMode.DEFAULT).withComputeType(ComputeType.DEFAULT)
.withEncryptionWithCmk(new EncryptionWithCmk().withEnforcement(SearchEncryptionWithCmk.ENABLED)),
null, com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
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_create_or_update_service_with_cmk_enforcement.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.services.begin_create_or_update(
resource_group_name="rg1",
search_service_name="mysearchservice",
service={
"location": "westus",
"properties": {
"computeType": "default",
"encryptionWithCmk": {"enforcement": "Enabled"},
"hostingMode": "default",
"partitionCount": 1,
"replicaCount": 3,
},
"sku": {"name": "standard"},
"tags": {"app-name": "My e-commerce app"},
},
).result()
print(response)
# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceWithCmkEnforcement.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/azcore/to"
"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/fb3217991ff57b5760525aeba1a0670bfe0880fa/specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceWithCmkEnforcement.json
func ExampleServicesClient_BeginCreateOrUpdate_searchCreateOrUpdateServiceWithCmkEnforcement() {
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)
}
poller, err := clientFactory.NewServicesClient().BeginCreateOrUpdate(ctx, "rg1", "mysearchservice", armsearch.Service{
Location: to.Ptr("westus"),
Tags: map[string]*string{
"app-name": to.Ptr("My e-commerce app"),
},
Properties: &armsearch.ServiceProperties{
ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
EncryptionWithCmk: &armsearch.EncryptionWithCmk{
Enforcement: to.Ptr(armsearch.SearchEncryptionWithCmkEnabled),
},
HostingMode: to.Ptr(armsearch.HostingModeDefault),
PartitionCount: to.Ptr[int32](1),
ReplicaCount: to.Ptr[int32](3),
},
SKU: &armsearch.SKU{
Name: to.Ptr(armsearch.SKUNameStandard),
},
}, &armsearch.SearchManagementRequestOptions{ClientRequestID: nil}, 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.Service = armsearch.Service{
// Name: to.Ptr("mysearchservice"),
// Type: to.Ptr("Microsoft.Search/searchServices"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice"),
// SystemData: &armsearch.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-01-01T00:00:00.000Z"); return t}()),
// CreatedBy: to.Ptr("My e-commerce app"),
// CreatedByType: to.Ptr(armsearch.CreatedByTypeApplication),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-01T00:00:00.000Z"); return t}()),
// LastModifiedBy: to.Ptr("fakeuser@contoso.com"),
// LastModifiedByType: to.Ptr(armsearch.CreatedByTypeUser),
// },
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "app-name": to.Ptr("My e-commerce app"),
// },
// Properties: &armsearch.ServiceProperties{
// AuthOptions: &armsearch.DataPlaneAuthOptions{
// APIKeyOnly: map[string]any{
// },
// },
// ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
// DataExfiltrationProtections: []*armsearch.SearchDataExfiltrationProtection{
// },
// DisableLocalAuth: to.Ptr(false),
// EncryptionWithCmk: &armsearch.EncryptionWithCmk{
// EncryptionComplianceStatus: to.Ptr(armsearch.SearchEncryptionComplianceStatusCompliant),
// Enforcement: to.Ptr(armsearch.SearchEncryptionWithCmkEnabled),
// },
// Endpoint: to.Ptr("https://mysearchservice.search.windows.net/"),
// HostingMode: to.Ptr(armsearch.HostingModeDefault),
// NetworkRuleSet: &armsearch.NetworkRuleSet{
// Bypass: to.Ptr(armsearch.SearchBypassNone),
// IPRules: []*armsearch.IPRule{
// },
// },
// PartitionCount: to.Ptr[int32](1),
// PrivateEndpointConnections: []*armsearch.PrivateEndpointConnection{
// },
// ProvisioningState: to.Ptr(armsearch.ProvisioningStateSucceeded),
// PublicNetworkAccess: to.Ptr(armsearch.PublicNetworkAccessEnabled),
// ReplicaCount: to.Ptr[int32](3),
// SharedPrivateLinkResources: []*armsearch.SharedPrivateLinkResource{
// },
// Status: to.Ptr(armsearch.SearchServiceStatusProvisioning),
// StatusDetails: to.Ptr(""),
// UpgradeAvailable: to.Ptr(armsearch.UpgradeAvailableNotAvailable),
// },
// SKU: &armsearch.SKU{
// Name: to.Ptr(armsearch.SKUNameStandard),
// },
// }
}
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");
require("dotenv/config");
/**
* This sample demonstrates how to Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
*
* @summary Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceWithCmkEnforcement.json
*/
async function searchCreateOrUpdateServiceWithCmkEnforcement() {
const subscriptionId = process.env["SEARCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["SEARCH_RESOURCE_GROUP"] || "rg1";
const searchServiceName = "mysearchservice";
const service = {
computeType: "default",
encryptionWithCmk: { enforcement: "Enabled" },
hostingMode: "default",
location: "westus",
partitionCount: 1,
replicaCount: 3,
sku: { name: "standard" },
tags: { appName: "My e-commerce app" },
};
const credential = new DefaultAzureCredential();
const client = new SearchManagementClient(credential, subscriptionId);
const result = await client.services.beginCreateOrUpdateAndWait(
resourceGroupName,
searchServiceName,
service,
);
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Search.Models;
using Azure.ResourceManager.Search;
// Generated from example definition: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceWithCmkEnforcement.json
// this example is just showing the usage of "Services_CreateOrUpdate" 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://free.blessedness.top/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this SearchServiceResource
SearchServiceCollection collection = resourceGroupResource.GetSearchServices();
// invoke the operation
string searchServiceName = "mysearchservice";
SearchServiceData data = new SearchServiceData(new AzureLocation("westus"))
{
SearchSkuName = SearchServiceSkuName.Standard,
ReplicaCount = 3,
PartitionCount = 1,
HostingMode = SearchServiceHostingMode.Default,
ComputeType = SearchServiceComputeType.Default,
EncryptionWithCmk = new SearchEncryptionWithCmk
{
Enforcement = SearchEncryptionWithCmkEnforcement.Enabled,
},
Tags =
{
["app-name"] = "My e-commerce app"
},
};
ArmOperation<SearchServiceResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data);
SearchServiceResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SearchServiceData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Enabled",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Enabled",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
SearchCreateOrUpdateServiceWithDataExfiltration
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice?api-version=2025-05-01
{
"location": "westus",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"hostingMode": "default",
"computeType": "default",
"dataExfiltrationProtections": [
"BlockAll"
]
}
}
import com.azure.resourcemanager.search.fluent.models.SearchServiceInner;
import com.azure.resourcemanager.search.models.ComputeType;
import com.azure.resourcemanager.search.models.HostingMode;
import com.azure.resourcemanager.search.models.SearchDataExfiltrationProtection;
import com.azure.resourcemanager.search.models.Sku;
import com.azure.resourcemanager.search.models.SkuName;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Services CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/
* SearchCreateOrUpdateServiceWithDataExfiltration.json
*/
/**
* Sample code: SearchCreateOrUpdateServiceWithDataExfiltration.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
searchCreateOrUpdateServiceWithDataExfiltration(com.azure.resourcemanager.AzureResourceManager azure) {
azure.searchServices().manager().serviceClient().getServices().createOrUpdate("rg1", "mysearchservice",
new SearchServiceInner().withLocation("westus").withTags(mapOf("app-name", "My e-commerce app"))
.withSku(new Sku().withName(SkuName.STANDARD)).withReplicaCount(3).withPartitionCount(1)
.withHostingMode(HostingMode.DEFAULT).withComputeType(ComputeType.DEFAULT)
.withDataExfiltrationProtections(Arrays.asList(SearchDataExfiltrationProtection.BLOCK_ALL)),
null, com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
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_create_or_update_service_with_data_exfiltration.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.services.begin_create_or_update(
resource_group_name="rg1",
search_service_name="mysearchservice",
service={
"location": "westus",
"properties": {
"computeType": "default",
"dataExfiltrationProtections": ["BlockAll"],
"hostingMode": "default",
"partitionCount": 1,
"replicaCount": 3,
},
"sku": {"name": "standard"},
"tags": {"app-name": "My e-commerce app"},
},
).result()
print(response)
# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceWithDataExfiltration.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/azcore/to"
"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/fb3217991ff57b5760525aeba1a0670bfe0880fa/specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceWithDataExfiltration.json
func ExampleServicesClient_BeginCreateOrUpdate_searchCreateOrUpdateServiceWithDataExfiltration() {
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)
}
poller, err := clientFactory.NewServicesClient().BeginCreateOrUpdate(ctx, "rg1", "mysearchservice", armsearch.Service{
Location: to.Ptr("westus"),
Tags: map[string]*string{
"app-name": to.Ptr("My e-commerce app"),
},
Properties: &armsearch.ServiceProperties{
ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
DataExfiltrationProtections: []*armsearch.SearchDataExfiltrationProtection{
to.Ptr(armsearch.SearchDataExfiltrationProtectionBlockAll)},
HostingMode: to.Ptr(armsearch.HostingModeDefault),
PartitionCount: to.Ptr[int32](1),
ReplicaCount: to.Ptr[int32](3),
},
SKU: &armsearch.SKU{
Name: to.Ptr(armsearch.SKUNameStandard),
},
}, &armsearch.SearchManagementRequestOptions{ClientRequestID: nil}, 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.Service = armsearch.Service{
// Name: to.Ptr("mysearchservice"),
// Type: to.Ptr("Microsoft.Search/searchServices"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice"),
// SystemData: &armsearch.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-01-01T00:00:00.000Z"); return t}()),
// CreatedBy: to.Ptr("My e-commerce app"),
// CreatedByType: to.Ptr(armsearch.CreatedByTypeApplication),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-01T00:00:00.000Z"); return t}()),
// LastModifiedBy: to.Ptr("fakeuser@contoso.com"),
// LastModifiedByType: to.Ptr(armsearch.CreatedByTypeUser),
// },
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "app-name": to.Ptr("My e-commerce app"),
// },
// Properties: &armsearch.ServiceProperties{
// AuthOptions: &armsearch.DataPlaneAuthOptions{
// APIKeyOnly: map[string]any{
// },
// },
// ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
// DataExfiltrationProtections: []*armsearch.SearchDataExfiltrationProtection{
// to.Ptr(armsearch.SearchDataExfiltrationProtectionBlockAll)},
// DisableLocalAuth: to.Ptr(false),
// EncryptionWithCmk: &armsearch.EncryptionWithCmk{
// EncryptionComplianceStatus: to.Ptr(armsearch.SearchEncryptionComplianceStatusCompliant),
// Enforcement: to.Ptr(armsearch.SearchEncryptionWithCmkUnspecified),
// },
// Endpoint: to.Ptr("https://mysearchservice.search.windows.net/"),
// HostingMode: to.Ptr(armsearch.HostingModeDefault),
// NetworkRuleSet: &armsearch.NetworkRuleSet{
// Bypass: to.Ptr(armsearch.SearchBypassNone),
// IPRules: []*armsearch.IPRule{
// },
// },
// PartitionCount: to.Ptr[int32](1),
// PrivateEndpointConnections: []*armsearch.PrivateEndpointConnection{
// },
// ProvisioningState: to.Ptr(armsearch.ProvisioningStateSucceeded),
// PublicNetworkAccess: to.Ptr(armsearch.PublicNetworkAccessEnabled),
// ReplicaCount: to.Ptr[int32](3),
// SharedPrivateLinkResources: []*armsearch.SharedPrivateLinkResource{
// },
// Status: to.Ptr(armsearch.SearchServiceStatusProvisioning),
// StatusDetails: to.Ptr(""),
// UpgradeAvailable: to.Ptr(armsearch.UpgradeAvailableNotAvailable),
// },
// SKU: &armsearch.SKU{
// Name: to.Ptr(armsearch.SKUNameStandard),
// },
// }
}
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");
require("dotenv/config");
/**
* This sample demonstrates how to Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
*
* @summary Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceWithDataExfiltration.json
*/
async function searchCreateOrUpdateServiceWithDataExfiltration() {
const subscriptionId = process.env["SEARCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["SEARCH_RESOURCE_GROUP"] || "rg1";
const searchServiceName = "mysearchservice";
const service = {
computeType: "default",
dataExfiltrationProtections: ["BlockAll"],
hostingMode: "default",
location: "westus",
partitionCount: 1,
replicaCount: 3,
sku: { name: "standard" },
tags: { appName: "My e-commerce app" },
};
const credential = new DefaultAzureCredential();
const client = new SearchManagementClient(credential, subscriptionId);
const result = await client.services.beginCreateOrUpdateAndWait(
resourceGroupName,
searchServiceName,
service,
);
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Search.Models;
using Azure.ResourceManager.Search;
// Generated from example definition: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceWithDataExfiltration.json
// this example is just showing the usage of "Services_CreateOrUpdate" 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://free.blessedness.top/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this SearchServiceResource
SearchServiceCollection collection = resourceGroupResource.GetSearchServices();
// invoke the operation
string searchServiceName = "mysearchservice";
SearchServiceData data = new SearchServiceData(new AzureLocation("westus"))
{
SearchSkuName = SearchServiceSkuName.Standard,
ReplicaCount = 3,
PartitionCount = 1,
HostingMode = SearchServiceHostingMode.Default,
ComputeType = SearchServiceComputeType.Default,
DataExfiltrationProtections = { SearchDataExfiltrationProtection.BlockAll },
Tags =
{
["app-name"] = "My e-commerce app"
},
};
ArmOperation<SearchServiceResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data);
SearchServiceResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SearchServiceData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [
"BlockAll"
],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [
"BlockAll"
],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
SearchCreateOrUpdateServiceWithIdentity
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice?api-version=2025-05-01
{
"location": "westus",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"hostingMode": "default",
"computeType": "default"
},
"identity": {
"type": "SystemAssigned, UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/user-mi": {}
}
}
}
import com.azure.resourcemanager.search.fluent.models.SearchServiceInner;
import com.azure.resourcemanager.search.models.ComputeType;
import com.azure.resourcemanager.search.models.HostingMode;
import com.azure.resourcemanager.search.models.Identity;
import com.azure.resourcemanager.search.models.IdentityType;
import com.azure.resourcemanager.search.models.Sku;
import com.azure.resourcemanager.search.models.SkuName;
import com.azure.resourcemanager.search.models.UserAssignedIdentity;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Services CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/
* SearchCreateOrUpdateServiceWithIdentity.json
*/
/**
* Sample code: SearchCreateOrUpdateServiceWithIdentity.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void searchCreateOrUpdateServiceWithIdentity(com.azure.resourcemanager.AzureResourceManager azure) {
azure.searchServices().manager().serviceClient().getServices().createOrUpdate("rg1", "mysearchservice",
new SearchServiceInner().withLocation("westus").withTags(mapOf("app-name", "My e-commerce app"))
.withSku(new Sku().withName(SkuName.STANDARD))
.withIdentity(new Identity().withType(IdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
.withUserAssignedIdentities(mapOf(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/user-mi",
new UserAssignedIdentity())))
.withReplicaCount(3).withPartitionCount(1).withHostingMode(HostingMode.DEFAULT)
.withComputeType(ComputeType.DEFAULT),
null, com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
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_create_or_update_service_with_identity.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.services.begin_create_or_update(
resource_group_name="rg1",
search_service_name="mysearchservice",
service={
"identity": {
"type": "SystemAssigned, UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/user-mi": {}
},
},
"location": "westus",
"properties": {"computeType": "default", "hostingMode": "default", "partitionCount": 1, "replicaCount": 3},
"sku": {"name": "standard"},
"tags": {"app-name": "My e-commerce app"},
},
).result()
print(response)
# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceWithIdentity.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/azcore/to"
"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/fb3217991ff57b5760525aeba1a0670bfe0880fa/specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceWithIdentity.json
func ExampleServicesClient_BeginCreateOrUpdate_searchCreateOrUpdateServiceWithIdentity() {
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)
}
poller, err := clientFactory.NewServicesClient().BeginCreateOrUpdate(ctx, "rg1", "mysearchservice", armsearch.Service{
Location: to.Ptr("westus"),
Tags: map[string]*string{
"app-name": to.Ptr("My e-commerce app"),
},
Identity: &armsearch.Identity{
Type: to.Ptr(armsearch.IdentityTypeSystemAssignedUserAssigned),
UserAssignedIdentities: map[string]*armsearch.UserAssignedIdentity{
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/user-mi": {},
},
},
Properties: &armsearch.ServiceProperties{
ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
HostingMode: to.Ptr(armsearch.HostingModeDefault),
PartitionCount: to.Ptr[int32](1),
ReplicaCount: to.Ptr[int32](3),
},
SKU: &armsearch.SKU{
Name: to.Ptr(armsearch.SKUNameStandard),
},
}, &armsearch.SearchManagementRequestOptions{ClientRequestID: nil}, 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.Service = armsearch.Service{
// Name: to.Ptr("mysearchservice"),
// Type: to.Ptr("Microsoft.Search/searchServices"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice"),
// SystemData: &armsearch.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-01-01T00:00:00.000Z"); return t}()),
// CreatedBy: to.Ptr("My e-commerce app"),
// CreatedByType: to.Ptr(armsearch.CreatedByTypeApplication),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-01T00:00:00.000Z"); return t}()),
// LastModifiedBy: to.Ptr("fakeuser@contoso.com"),
// LastModifiedByType: to.Ptr(armsearch.CreatedByTypeUser),
// },
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "app-name": to.Ptr("My e-commerce app"),
// },
// Identity: &armsearch.Identity{
// Type: to.Ptr(armsearch.IdentityTypeSystemAssignedUserAssigned),
// PrincipalID: to.Ptr("9d1e1f18-2122-4988-a11c-878782e40a5c"),
// TenantID: to.Ptr("f686d426-8d16-42db-81b7-ab578e110ccd"),
// UserAssignedIdentities: map[string]*armsearch.UserAssignedIdentity{
// "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/user-mi": &armsearch.UserAssignedIdentity{
// ClientID: to.Ptr("cd1dcac8-82dd-45b5-9aed-76795d529f6b"),
// PrincipalID: to.Ptr("24e07a75-1286-41e5-a15d-ded85ec3acd7"),
// },
// },
// },
// Properties: &armsearch.ServiceProperties{
// AuthOptions: &armsearch.DataPlaneAuthOptions{
// APIKeyOnly: map[string]any{
// },
// },
// ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
// DataExfiltrationProtections: []*armsearch.SearchDataExfiltrationProtection{
// },
// DisableLocalAuth: to.Ptr(false),
// EncryptionWithCmk: &armsearch.EncryptionWithCmk{
// EncryptionComplianceStatus: to.Ptr(armsearch.SearchEncryptionComplianceStatusCompliant),
// Enforcement: to.Ptr(armsearch.SearchEncryptionWithCmkUnspecified),
// },
// Endpoint: to.Ptr("https://mysearchservice.search.windows.net/"),
// HostingMode: to.Ptr(armsearch.HostingModeDefault),
// NetworkRuleSet: &armsearch.NetworkRuleSet{
// Bypass: to.Ptr(armsearch.SearchBypassNone),
// IPRules: []*armsearch.IPRule{
// },
// },
// PartitionCount: to.Ptr[int32](1),
// PrivateEndpointConnections: []*armsearch.PrivateEndpointConnection{
// },
// ProvisioningState: to.Ptr(armsearch.ProvisioningStateSucceeded),
// PublicNetworkAccess: to.Ptr(armsearch.PublicNetworkAccessEnabled),
// ReplicaCount: to.Ptr[int32](3),
// SharedPrivateLinkResources: []*armsearch.SharedPrivateLinkResource{
// },
// Status: to.Ptr(armsearch.SearchServiceStatusProvisioning),
// StatusDetails: to.Ptr(""),
// UpgradeAvailable: to.Ptr(armsearch.UpgradeAvailableNotAvailable),
// },
// SKU: &armsearch.SKU{
// Name: to.Ptr(armsearch.SKUNameStandard),
// },
// }
}
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");
require("dotenv/config");
/**
* This sample demonstrates how to Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
*
* @summary Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceWithIdentity.json
*/
async function searchCreateOrUpdateServiceWithIdentity() {
const subscriptionId = process.env["SEARCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["SEARCH_RESOURCE_GROUP"] || "rg1";
const searchServiceName = "mysearchservice";
const service = {
computeType: "default",
hostingMode: "default",
identity: {
type: "SystemAssigned, UserAssigned",
userAssignedIdentities: {
"/subscriptions/00000000000000000000000000000000/resourcegroups/rg1/providers/MicrosoftManagedIdentity/userAssignedIdentities/userMi":
{},
},
},
location: "westus",
partitionCount: 1,
replicaCount: 3,
sku: { name: "standard" },
tags: { appName: "My e-commerce app" },
};
const credential = new DefaultAzureCredential();
const client = new SearchManagementClient(credential, subscriptionId);
const result = await client.services.beginCreateOrUpdateAndWait(
resourceGroupName,
searchServiceName,
service,
);
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Search.Models;
using Azure.ResourceManager.Search;
// Generated from example definition: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateServiceWithIdentity.json
// this example is just showing the usage of "Services_CreateOrUpdate" 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://free.blessedness.top/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this SearchServiceResource
SearchServiceCollection collection = resourceGroupResource.GetSearchServices();
// invoke the operation
string searchServiceName = "mysearchservice";
SearchServiceData data = new SearchServiceData(new AzureLocation("westus"))
{
SearchSkuName = SearchServiceSkuName.Standard,
Identity = new ManagedServiceIdentity("SystemAssigned, UserAssigned")
{
UserAssignedIdentities =
{
[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/user-mi")] = new UserAssignedIdentity()
},
},
ReplicaCount = 3,
PartitionCount = 1,
HostingMode = SearchServiceHostingMode.Default,
ComputeType = SearchServiceComputeType.Default,
Tags =
{
["app-name"] = "My e-commerce app"
},
};
ArmOperation<SearchServiceResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data);
SearchServiceResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SearchServiceData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"identity": {
"type": "SystemAssigned, UserAssigned",
"principalId": "9d1e1f18-2122-4988-a11c-878782e40a5c",
"tenantId": "f686d426-8d16-42db-81b7-ab578e110ccd",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/user-mi": {
"clientId": "cd1dcac8-82dd-45b5-9aed-76795d529f6b",
"principalId": "24e07a75-1286-41e5-a15d-ded85ec3acd7"
}
}
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [],
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"identity": {
"type": "SystemAssigned, UserAssigned",
"principalId": "9d1e1f18-2122-4988-a11c-878782e40a5c",
"tenantId": "f686d426-8d16-42db-81b7-ab578e110ccd",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/user-mi": {
"clientId": "cd1dcac8-82dd-45b5-9aed-76795d529f6b",
"principalId": "24e07a75-1286-41e5-a15d-ded85ec3acd7"
}
}
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
SearchCreateOrUpdateWithSemanticSearch
示例请求
PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice?api-version=2025-05-01
{
"location": "westus",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"hostingMode": "default",
"computeType": "default",
"semanticSearch": "free"
}
}
import com.azure.resourcemanager.search.fluent.models.SearchServiceInner;
import com.azure.resourcemanager.search.models.ComputeType;
import com.azure.resourcemanager.search.models.HostingMode;
import com.azure.resourcemanager.search.models.SearchSemanticSearch;
import com.azure.resourcemanager.search.models.Sku;
import com.azure.resourcemanager.search.models.SkuName;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Services CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/
* SearchCreateOrUpdateWithSemanticSearch.json
*/
/**
* Sample code: SearchCreateOrUpdateWithSemanticSearch.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void searchCreateOrUpdateWithSemanticSearch(com.azure.resourcemanager.AzureResourceManager azure) {
azure.searchServices().manager().serviceClient().getServices().createOrUpdate("rg1", "mysearchservice",
new SearchServiceInner().withLocation("westus").withTags(mapOf("app-name", "My e-commerce app"))
.withSku(new Sku().withName(SkuName.STANDARD)).withReplicaCount(3).withPartitionCount(1)
.withHostingMode(HostingMode.DEFAULT).withComputeType(ComputeType.DEFAULT)
.withSemanticSearch(SearchSemanticSearch.FREE),
null, com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
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_create_or_update_with_semantic_search.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.services.begin_create_or_update(
resource_group_name="rg1",
search_service_name="mysearchservice",
service={
"location": "westus",
"properties": {
"computeType": "default",
"hostingMode": "default",
"partitionCount": 1,
"replicaCount": 3,
"semanticSearch": "free",
},
"sku": {"name": "standard"},
"tags": {"app-name": "My e-commerce app"},
},
).result()
print(response)
# x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateWithSemanticSearch.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/azcore/to"
"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/fb3217991ff57b5760525aeba1a0670bfe0880fa/specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateWithSemanticSearch.json
func ExampleServicesClient_BeginCreateOrUpdate_searchCreateOrUpdateWithSemanticSearch() {
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)
}
poller, err := clientFactory.NewServicesClient().BeginCreateOrUpdate(ctx, "rg1", "mysearchservice", armsearch.Service{
Location: to.Ptr("westus"),
Tags: map[string]*string{
"app-name": to.Ptr("My e-commerce app"),
},
Properties: &armsearch.ServiceProperties{
ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
HostingMode: to.Ptr(armsearch.HostingModeDefault),
PartitionCount: to.Ptr[int32](1),
ReplicaCount: to.Ptr[int32](3),
SemanticSearch: to.Ptr(armsearch.SearchSemanticSearchFree),
},
SKU: &armsearch.SKU{
Name: to.Ptr(armsearch.SKUNameStandard),
},
}, &armsearch.SearchManagementRequestOptions{ClientRequestID: nil}, 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.Service = armsearch.Service{
// Name: to.Ptr("mysearchservice"),
// Type: to.Ptr("Microsoft.Search/searchServices"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice"),
// SystemData: &armsearch.SystemData{
// CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-01-01T00:00:00.000Z"); return t}()),
// CreatedBy: to.Ptr("My e-commerce app"),
// CreatedByType: to.Ptr(armsearch.CreatedByTypeApplication),
// LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-11-01T00:00:00.000Z"); return t}()),
// LastModifiedBy: to.Ptr("fakeuser@contoso.com"),
// LastModifiedByType: to.Ptr(armsearch.CreatedByTypeUser),
// },
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "app-name": to.Ptr("My e-commerce app"),
// },
// Properties: &armsearch.ServiceProperties{
// AuthOptions: &armsearch.DataPlaneAuthOptions{
// APIKeyOnly: map[string]any{
// },
// },
// ComputeType: to.Ptr(armsearch.ComputeTypeDefault),
// DataExfiltrationProtections: []*armsearch.SearchDataExfiltrationProtection{
// },
// DisableLocalAuth: to.Ptr(false),
// EncryptionWithCmk: &armsearch.EncryptionWithCmk{
// EncryptionComplianceStatus: to.Ptr(armsearch.SearchEncryptionComplianceStatusCompliant),
// Enforcement: to.Ptr(armsearch.SearchEncryptionWithCmkUnspecified),
// },
// Endpoint: to.Ptr("https://mysearchservice.search.windows.net/"),
// HostingMode: to.Ptr(armsearch.HostingModeDefault),
// NetworkRuleSet: &armsearch.NetworkRuleSet{
// Bypass: to.Ptr(armsearch.SearchBypassNone),
// IPRules: []*armsearch.IPRule{
// },
// },
// PartitionCount: to.Ptr[int32](1),
// PrivateEndpointConnections: []*armsearch.PrivateEndpointConnection{
// },
// ProvisioningState: to.Ptr(armsearch.ProvisioningStateSucceeded),
// PublicNetworkAccess: to.Ptr(armsearch.PublicNetworkAccessEnabled),
// ReplicaCount: to.Ptr[int32](3),
// SemanticSearch: to.Ptr(armsearch.SearchSemanticSearchFree),
// SharedPrivateLinkResources: []*armsearch.SharedPrivateLinkResource{
// },
// Status: to.Ptr(armsearch.SearchServiceStatusProvisioning),
// StatusDetails: to.Ptr(""),
// UpgradeAvailable: to.Ptr(armsearch.UpgradeAvailableNotAvailable),
// },
// SKU: &armsearch.SKU{
// Name: to.Ptr(armsearch.SKUNameStandard),
// },
// }
}
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");
require("dotenv/config");
/**
* This sample demonstrates how to Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
*
* @summary Creates or updates a search service in the given resource group. If the search service already exists, all properties will be updated with the given values.
* x-ms-original-file: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateWithSemanticSearch.json
*/
async function searchCreateOrUpdateWithSemanticSearch() {
const subscriptionId = process.env["SEARCH_SUBSCRIPTION_ID"] || "subid";
const resourceGroupName = process.env["SEARCH_RESOURCE_GROUP"] || "rg1";
const searchServiceName = "mysearchservice";
const service = {
computeType: "default",
hostingMode: "default",
location: "westus",
partitionCount: 1,
replicaCount: 3,
semanticSearch: "free",
sku: { name: "standard" },
tags: { appName: "My e-commerce app" },
};
const credential = new DefaultAzureCredential();
const client = new SearchManagementClient(credential, subscriptionId);
const result = await client.services.beginCreateOrUpdateAndWait(
resourceGroupName,
searchServiceName,
service,
);
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.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Search.Models;
using Azure.ResourceManager.Search;
// Generated from example definition: specification/search/resource-manager/Microsoft.Search/stable/2025-05-01/examples/SearchCreateOrUpdateWithSemanticSearch.json
// this example is just showing the usage of "Services_CreateOrUpdate" 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://free.blessedness.top/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 ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "subid";
string resourceGroupName = "rg1";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this SearchServiceResource
SearchServiceCollection collection = resourceGroupResource.GetSearchServices();
// invoke the operation
string searchServiceName = "mysearchservice";
SearchServiceData data = new SearchServiceData(new AzureLocation("westus"))
{
SearchSkuName = SearchServiceSkuName.Standard,
ReplicaCount = 3,
PartitionCount = 1,
HostingMode = SearchServiceHostingMode.Default,
ComputeType = SearchServiceComputeType.Default,
SemanticSearch = SearchSemanticSearch.Free,
Tags =
{
["app-name"] = "My e-commerce app"
},
};
ArmOperation<SearchServiceResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data);
SearchServiceResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SearchServiceData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
示例响应
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [],
"semanticSearch": "free",
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice",
"name": "mysearchservice",
"location": "westus",
"type": "Microsoft.Search/searchServices",
"tags": {
"app-name": "My e-commerce app"
},
"sku": {
"name": "standard"
},
"properties": {
"replicaCount": 3,
"partitionCount": 1,
"endpoint": "https://mysearchservice.search.windows.net/",
"status": "provisioning",
"statusDetails": "",
"hostingMode": "default",
"computeType": "default",
"provisioningState": "provisioning",
"publicNetworkAccess": "enabled",
"networkRuleSet": {
"ipRules": [],
"bypass": "None"
},
"privateEndpointConnections": [],
"sharedPrivateLinkResources": [],
"encryptionWithCmk": {
"enforcement": "Unspecified",
"encryptionComplianceStatus": "Compliant"
},
"disableLocalAuth": false,
"authOptions": {
"apiKeyOnly": {}
},
"dataExfiltrationProtections": [],
"semanticSearch": "free",
"upgradeAvailable": "notAvailable",
"serviceUpgradedAt": null
},
"systemData": {
"createdBy": "My e-commerce app",
"createdByType": "Application",
"createdAt": "2024-01-01T00:00:00Z",
"lastModifiedBy": "fakeuser@contoso.com",
"lastModifiedByType": "User",
"lastModifiedAt": "2024-11-01T00:00:00Z"
}
}
定义
AadAuthFailureMode
枚举
描述搜索服务的数据平面 API 针对身份验证失败的请求发送的响应。
| 值 |
说明 |
|
http403
|
指示失败身份验证的请求应显示 HTTP 状态代码 403(禁止)。
|
|
http401WithBearerChallenge
|
指示失败身份验证的请求应显示 HTTP 状态代码 401(未授权),并提出持有者质询。
|
ApiKeyOnly
Object
指示只能使用 API 密钥进行身份验证。
CloudError
Object
包含有关 API 错误的信息。
| 名称 |
类型 |
说明 |
|
error
|
CloudErrorBody
|
描述具有错误代码和消息的特定 API 错误。
|
|
message
|
string
|
提示出错的错误的简要说明(有关详细信息/调试信息,请参阅“error.message”属性)。
|
CloudErrorBody
Object
描述具有错误代码和消息的特定 API 错误。
| 名称 |
类型 |
说明 |
|
code
|
string
|
比 HTTP 状态代码更准确地描述错误条件的错误代码。 可用于以编程方式处理特定错误案例。
|
|
details
|
CloudErrorBody[]
|
包含与此错误相关的嵌套错误。
|
|
message
|
string
|
详细说明错误并提供调试信息的消息。
|
|
target
|
string
|
特定错误的目标(例如,错误中属性的名称)。
|
ComputeType
枚举
配置此属性以支持使用默认计算或 Azure 机密计算的搜索服务。
| 值 |
说明 |
|
default
|
使用默认计算创建服务。
|
|
confidential
|
使用 Azure 机密计算创建服务。
|
createdByType
枚举
创建资源的标识的类型。
| 值 |
说明 |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
DataPlaneAadOrApiKeyAuthOption
Object
指示 API 密钥或来自 Microsoft Entra ID 租户的访问令牌可用于身份验证。
DataPlaneAuthOptions
Object
定义搜索服务如何对数据平面请求进行身份验证的选项。 如果“disableLocalAuth”设置为 true,则无法设置此项。
EncryptionWithCmk
Object
描述一个策略,该策略确定如何使用客户管理的密钥对搜索服务中的资源进行加密。
HostingMode
枚举
仅适用于 standard3 SKU。 可以将此属性设置为最多允许 3 个高密度分区,允许最多 1000 个索引,这远远高于任何其他 SKU 允许的最大索引。 对于 standard3 SKU,该值为“default”或“highDensity”。 对于所有其他 SKU,此值必须为“default”。
| 值 |
说明 |
|
default
|
索引数限制取决于 SKU 的默认限制。
|
|
highDensity
|
只有 standard3 SKU 的应用程序,其中搜索服务最多可以有 1000 个索引。
|
Identity
Object
有关搜索服务标识的详细信息。 null 值指示搜索服务未分配标识。
| 名称 |
类型 |
说明 |
|
principalId
|
string
|
搜索服务的系统分配标识的主体 ID。
|
|
tenantId
|
string
|
搜索服务的系统分配标识的租户 ID。
|
|
type
|
IdentityType
|
用于资源的标识类型。 类型“SystemAssigned, UserAssigned”包含系统创建的一个标识,以及用户分配的一组标识。 类型“None”将从服务中删除所有标识。
|
|
userAssignedIdentities
|
<string,
UserAssignedIdentity>
|
与资源关联的用户标识列表。 用户标识字典密钥引用的格式为 ARM 资源 ID:“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}”。
|
IdentityType
枚举
用于资源的标识类型。 类型“SystemAssigned, UserAssigned”包含系统创建的一个标识,以及用户分配的一组标识。 类型“None”将从服务中删除所有标识。
| 值 |
说明 |
|
None
|
指示需要删除与搜索服务关联的任何标识。
|
|
SystemAssigned
|
指示将启用搜索服务的系统分配标识。
|
|
UserAssigned
|
指示将向搜索服务分配一个或多个用户分配的标识。
|
|
SystemAssigned, UserAssigned
|
指示将启用搜索服务的系统分配标识以及分配一个或多个用户分配的标识。
|
IpRule
Object
Azure AI 搜索服务的 IP 限制规则。
| 名称 |
类型 |
说明 |
|
value
|
string
|
与单个 IPv4 地址(例如,123.1.2.3)或 CIDR 格式(例如,允许 123.1.2.3/24)的 IP 范围对应的值。
|
NetworkRuleSet
Object
确定如何访问 Azure AI 搜索服务的网络特定规则。
| 名称 |
类型 |
说明 |
|
bypass
|
SearchBypass
|
可以绕过“ipRules”部分中定义的规则的入站流量的可能来源。
|
|
ipRules
|
IpRule[]
|
定义入站网络(s)的 IP 限制规则列表,允许访问搜索服务终结点。 同时,防火墙会阻止所有其他公共 IP 网络。 仅当搜索服务的“publicNetworkAccess”为“enabled”时,才应用这些限制规则;否则,即使使用任何公共 IP 规则,也不允许通过公共接口的流量,专用终结点连接将是独占访问方法。
|
PrivateEndpoint
Object
来自 Microsoft.Network 提供程序的专用终结点资源。
| 名称 |
类型 |
说明 |
|
id
|
string
|
来自 Microsoft.Network 提供程序的专用终结点资源的资源 ID。
|
PrivateEndpointConnection
Object
描述与 Azure AI 搜索服务的现有专用终结点连接。
| 名称 |
类型 |
说明 |
|
id
|
string
(arm-id)
|
资源的完全限定资源 ID。 例如“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}”
|
|
name
|
string
|
资源的名称
|
|
properties
|
PrivateEndpointConnectionProperties
|
介绍与 Azure AI 搜索服务的现有专用终结点连接的属性。
|
|
systemData
|
systemData
|
包含 createdBy 和 modifiedBy 信息的 Azure 资源管理器元数据。
|
|
type
|
string
|
资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
PrivateEndpointConnectionProperties
Object
描述与搜索服务的现有专用终结点连接的属性。
PrivateLinkServiceConnectionProvisioningState
枚举
专用链接服务连接的预配状态。 有效值为“正在更新”、“删除”、“失败”、“成功”、“不完整”或“已取消”。
| 值 |
说明 |
|
Updating
|
专用链接服务连接正在与其他资源一起创建,以便其功能完全正常运行。
|
|
Deleting
|
正在删除专用链接服务连接。
|
|
Failed
|
无法预配或删除专用链接服务连接。
|
|
Succeeded
|
专用链接服务连接已完成预配,可供审批。
|
|
Incomplete
|
已接受专用链接服务连接资源的预配请求,但尚未开始创建过程。
|
|
Canceled
|
已取消专用链接服务连接资源的预配请求。
|
PrivateLinkServiceConnectionState
Object
描述与专用终结点的现有 Azure 专用链接服务连接的当前状态。
| 名称 |
类型 |
默认值 |
说明 |
|
actionsRequired
|
string
|
None
|
对可能需要执行的任何额外操作的说明。
|
|
description
|
string
|
|
专用链接服务连接状态的说明。
|
|
status
|
PrivateLinkServiceConnectionStatus
|
|
专用链接服务连接的状态。 有效值为 Pending、Approved、Rejected 或 Disconnected。
|
PrivateLinkServiceConnectionStatus
枚举
专用链接服务连接的状态。 有效值为 Pending、Approved、Rejected 或 Disconnected。
| 值 |
说明 |
|
Pending
|
已创建专用终结点连接,并且正在等待审批。
|
|
Approved
|
专用终结点连接已获批准,可供使用。
|
|
Rejected
|
专用终结点连接已被拒绝,不能使用。
|
|
Disconnected
|
专用终结点连接已从服务中删除。
|
ProvisioningState
枚举
对搜索服务执行的最后一个预配操作的状态。 预配是在建立服务容量时发生的中间状态。 设置容量后,provisioningState 将更改为“Succeeded”或“Failed”。 客户端应用程序可以使用“获取搜索服务”操作来轮询预配状态(建议的轮询间隔为 30 秒到 1 分钟),以查看操作何时完成。 如果使用免费服务,此值在调用“创建搜索服务”时倾向于直接返回为“Succeeded”。 这是因为免费服务使用已设置的容量。
| 值 |
说明 |
|
succeeded
|
上次预配操作已成功完成。
|
|
provisioning
|
正在预配或纵向扩展或缩减搜索服务。
|
|
failed
|
上次预配操作失败。
|
PublicNetworkAccess
枚举
此值可以设置为“已启用”,以避免对现有客户资源和模板进行重大更改。 如果设置为“disabled”,则不允许通过公共接口的流量,专用终结点连接将是独占访问方法。
| 值 |
说明 |
|
enabled
|
可从源自公共 Internet 的流量访问搜索服务。
|
|
disabled
|
无法从源自公共 Internet 的流量访问搜索服务。 仅允许通过批准的专用终结点连接进行访问。
|
SearchBypass
枚举
可以绕过“ipRules”部分中定义的规则的入站流量的可能来源。
| 值 |
说明 |
|
None
|
指示没有源可以绕过“ipRules”部分中定义的规则。 这是默认值。
|
|
AzureServices
|
指示源自 Azure 受信任服务的请求可以绕过“ipRules”部分中定义的规则。
|
SearchDataExfiltrationProtection
枚举
显式禁止搜索服务的数据外泄方案列表。 目前,唯一支持的值是“全部”,用于禁用所有可能的数据导出方案,并计划将来进行更精细的控制。
| 值 |
说明 |
|
BlockAll
|
指示禁用所有数据外泄方案。
|
SearchEncryptionComplianceStatus
枚举
返回与非 CMK 加密对象相关的搜索服务符合性的状态。 如果某个服务具有多个未加密的对象,并且已启用强制,则服务将标记为不符合。
| 值 |
说明 |
|
Compliant
|
指示搜索服务符合要求,要么是因为非 CMK 加密的对象数为零,要么禁用强制。
|
|
NonCompliant
|
指示搜索服务具有多个非 CMK 加密的对象。
|
SearchEncryptionWithCmk
枚举
描述如果搜索服务查找未使用客户管理的密钥加密的对象,则搜索服务应如何强制实施符合性。
| 值 |
说明 |
|
Disabled
|
不会强制实施客户管理的密钥加密。 仅使用内置服务托管加密。
|
|
Enabled
|
如果未使用客户管理的密钥加密一个或多个对象,搜索服务将标记为不合规。
|
|
Unspecified
|
未显式指定强制策略,其行为与设置为“Disabled”的行为相同。
|
SearchSemanticSearch
枚举
设置控制语义搜索可用性的选项。 此配置仅适用于特定位置的某些 Azure AI 搜索 SKU。
| 值 |
说明 |
|
disabled
|
指示为搜索服务禁用语义重新调用程序。 这是默认值。
|
|
free
|
在搜索服务上启用语义重新编制器,并指示它在免费计划的限制内使用。 免费计划将限制语义排名请求的数量,并免费提供。 这是新预配的搜索服务的默认值。
|
|
standard
|
在搜索服务上启用语义重排器作为可计费功能,吞吐量和语义上重新调用的查询量更高。
|
SearchService
Object
介绍 Azure AI 搜索服务及其当前状态。
| 名称 |
类型 |
默认值 |
说明 |
|
id
|
string
(arm-id)
|
|
资源的完全限定资源 ID。 例如“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}”
|
|
identity
|
Identity
|
|
资源的标识。
|
|
location
|
string
|
|
资源所在的地理位置
|
|
name
|
string
|
|
资源的名称
|
|
properties.authOptions
|
DataPlaneAuthOptions
|
|
定义搜索服务的数据平面 API 如何对请求进行身份验证的选项。 如果“disableLocalAuth”设置为 true,则无法设置此项。
|
|
properties.computeType
|
ComputeType
|
|
配置此属性以支持使用默认计算或 Azure 机密计算的搜索服务。
|
|
properties.dataExfiltrationProtections
|
SearchDataExfiltrationProtection[]
|
|
显式禁止搜索服务的数据外泄方案列表。 目前,唯一支持的值是“全部”,用于禁用所有可能的数据导出方案,并计划将来进行更精细的控制。
|
|
properties.disableLocalAuth
|
boolean
|
|
如果设置为 true,则不允许调用搜索服务以使用 API 密钥进行身份验证。 如果定义了“dataPlaneAuthOptions”,则无法将其设置为 true。
|
|
properties.eTag
|
string
|
|
一个系统生成的属性,表示服务 etag,可用于在更新期间进行乐观并发控制。
|
|
properties.encryptionWithCmk
|
EncryptionWithCmk
|
|
指定有关使用搜索服务中的客户经理密钥加密资源(如索引)的任何策略。
|
|
properties.endpoint
|
string
(uri)
|
|
Azure AI 搜索服务的终结点。
|
|
properties.hostingMode
|
HostingMode
|
default
|
仅适用于 standard3 SKU。 可以将此属性设置为最多允许 3 个高密度分区,允许最多 1000 个索引,这远远高于任何其他 SKU 允许的最大索引。 对于 standard3 SKU,该值为“default”或“highDensity”。 对于所有其他 SKU,此值必须为“default”。
|
|
properties.networkRuleSet
|
NetworkRuleSet
|
|
确定如何访问 Azure AI 搜索服务的网络特定规则。
|
|
properties.partitionCount
|
integer
(int32)
minimum: 1 maximum: 12
|
1
|
搜索服务中的分区数;如果指定,则它可以是 1、2、3、4、6 或 12。 大于 1 的值仅适用于标准 SKU。 对于 hostingMode 设置为“highDensity”的“standard3”服务,允许的值介于 1 到 3 之间。
|
|
properties.privateEndpointConnections
|
PrivateEndpointConnection[]
|
|
与 Azure AI 搜索服务的专用终结点连接列表。
|
|
properties.provisioningState
|
ProvisioningState
|
|
对搜索服务执行的最后一个预配操作的状态。 预配是在建立服务容量时发生的中间状态。 设置容量后,provisioningState 将更改为“Succeeded”或“Failed”。 客户端应用程序可以使用“获取搜索服务”操作来轮询预配状态(建议的轮询间隔为 30 秒到 1 分钟),以查看操作何时完成。 如果使用免费服务,此值在调用“创建搜索服务”时倾向于直接返回为“Succeeded”。 这是因为免费服务使用已设置的容量。
|
|
properties.publicNetworkAccess
|
PublicNetworkAccess
|
enabled
|
此值可以设置为“已启用”,以避免对现有客户资源和模板进行重大更改。 如果设置为“disabled”,则不允许通过公共接口的流量,专用终结点连接将是独占访问方法。
|
|
properties.replicaCount
|
integer
(int32)
minimum: 1 maximum: 12
|
1
|
搜索服务中的副本数。 如果指定,它必须是标准 SKU 的 1 到 12(含 1 到 3)之间的值,对于基本 SKU,该值必须介于 1 和 3 之间。
|
|
properties.semanticSearch
|
SearchSemanticSearch
|
|
设置控制语义搜索可用性的选项。 此配置仅适用于特定位置的某些 Azure AI 搜索 SKU。
|
|
properties.serviceUpgradedAt
|
string
(date-time)
|
|
上次升级搜索服务的日期和时间。 此字段将为 null,直到服务首次升级。
|
|
properties.sharedPrivateLinkResources
|
SharedPrivateLinkResource[]
|
|
由 Azure AI 搜索服务管理的共享专用链接资源列表。
|
|
properties.status
|
SearchServiceStatus
|
|
搜索服务的状态。 可能的值包括:“running”:搜索服务正在运行,未执行任何预配操作。 “provisioning”:正在预配或纵向扩展或缩减搜索服务。 “delete”:正在删除搜索服务。 “已降级”:搜索服务已降级。 当基础搜索单元不正常时,可能会发生这种情况。 搜索服务最有可能正常运行,但性能可能很慢,某些请求可能会被删除。 “disabled”:已禁用搜索服务。 在此状态下,服务将拒绝所有 API 请求。 “error”:搜索服务处于错误状态。 “stopped”:搜索服务位于已禁用的订阅中。 如果服务处于降级、禁用或错误状态,则意味着 Azure AI 搜索团队正在积极调查根本问题。 根据预配的搜索单位数,这些状态中的专用服务仍可收费。
|
|
properties.statusDetails
|
string
|
|
搜索服务状态的详细信息。
|
|
properties.upgradeAvailable
|
UpgradeAvailable
|
|
指示搜索服务是否有可用的升级。
|
|
sku
|
Sku
|
|
搜索服务的 SKU,用于确定价格层和容量限制。 创建新搜索服务时,此属性是必需的。
|
|
systemData
|
systemData
|
|
包含 createdBy 和 modifiedBy 信息的搜索服务的 Azure 资源管理器元数据。
|
|
tags
|
object
|
|
资源标记。
|
|
type
|
string
|
|
资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
SearchServiceStatus
枚举
搜索服务的状态。 可能的值包括:“running”:搜索服务正在运行,未执行任何预配操作。 “provisioning”:正在预配或纵向扩展或缩减搜索服务。 “delete”:正在删除搜索服务。 “已降级”:搜索服务已降级。 当基础搜索单元不正常时,可能会发生这种情况。 搜索服务最有可能正常运行,但性能可能很慢,某些请求可能会被删除。 “disabled”:已禁用搜索服务。 在此状态下,服务将拒绝所有 API 请求。 “error”:搜索服务处于错误状态。 “stopped”:搜索服务位于已禁用的订阅中。 如果服务处于降级、禁用或错误状态,则意味着 Azure AI 搜索团队正在积极调查根本问题。 根据预配的搜索单位数,这些状态中的专用服务仍可收费。
| 值 |
说明 |
|
running
|
搜索服务正在运行,并且未执行任何预配操作。
|
|
provisioning
|
正在预配或纵向扩展或缩减搜索服务。
|
|
deleting
|
正在删除搜索服务。
|
|
degraded
|
搜索服务已降级,因为基础搜索单元不正常。
|
|
disabled
|
搜索服务已禁用,所有 API 请求都将被拒绝。
|
|
error
|
搜索服务处于错误状态,指示预配失败或被删除。
|
|
stopped
|
搜索服务位于禁用的订阅中。
|
SharedPrivateLinkResource
Object
介绍由 Azure AI 搜索服务管理的共享专用链接资源。
| 名称 |
类型 |
说明 |
|
id
|
string
(arm-id)
|
资源的完全限定资源 ID。 例如“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}”
|
|
name
|
string
|
资源的名称
|
|
properties
|
SharedPrivateLinkResourceProperties
|
介绍由 Azure AI 搜索服务管理的共享专用链接资源的属性。
|
|
systemData
|
systemData
|
包含 createdBy 和 modifiedBy 信息的 Azure 资源管理器元数据。
|
|
type
|
string
|
资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
SharedPrivateLinkResourceProperties
Object
介绍由 Azure AI 搜索服务管理的现有共享专用链接资源的属性。
| 名称 |
类型 |
说明 |
|
groupId
|
string
|
共享专用链接资源的提供程序中的组 ID。
|
|
privateLinkResourceId
|
string
|
共享专用链接资源的资源的资源 ID。
|
|
provisioningState
|
SharedPrivateLinkResourceProvisioningState
|
共享专用链接资源的预配状态。 有效值为更新、删除、失败、成功或不完整。
|
|
requestMessage
|
string
|
请求批准共享专用链接资源的消息。
|
|
resourceRegion
|
string
|
可选。 可用于指定要为其创建共享专用链接的资源的 Azure 资源管理器位置。 只有 DNS 配置是区域(例如 Azure Kubernetes 服务)的资源才需要这样做。
|
|
status
|
SharedPrivateLinkResourceStatus
|
共享专用链接资源的状态。 有效值为 Pending、Approved、Rejected 或 Disconnected。
|
SharedPrivateLinkResourceProvisioningState
枚举
共享专用链接资源的预配状态。 有效值为更新、删除、失败、成功或不完整。
| 值 |
说明 |
|
Updating
|
共享专用链接资源正在与其他资源一起创建,以便其功能完全正常运行。
|
|
Deleting
|
共享专用链接资源正在删除。
|
|
Failed
|
共享专用链接资源预配或删除失败。
|
|
Succeeded
|
共享专用链接资源已完成预配,可供审批。
|
|
Incomplete
|
已接受共享专用链接资源的预配请求,但尚未开始创建过程。
|
SharedPrivateLinkResourceStatus
枚举
共享专用链接资源的状态。 有效值为 Pending、Approved、Rejected 或 Disconnected。
| 值 |
说明 |
|
Pending
|
已创建共享专用链接资源,并等待审批。
|
|
Approved
|
共享专用链接资源已获批准,可供使用。
|
|
Rejected
|
共享专用链接资源已被拒绝,不能使用。
|
|
Disconnected
|
共享专用链接资源已从服务中删除。
|
Sku
Object
定义搜索服务的 SKU,用于确定计费费率和容量限制。
| 名称 |
类型 |
说明 |
|
name
|
SkuName
|
搜索服务的 SKU。 有效值包括:“free”:共享服务。 “basic”:最多包含 3 个副本的专用服务。 “standard”:最多包含 12 个分区和 12 个副本的专用服务。 “standard2”:类似于标准,但每个搜索单位的容量更多。 “standard3”:最大标准产品/服务最多包含 12 个分区和 12 个副本(如果同时将 hostingMode 属性设置为“highDensity”,则最多具有 3 个具有更多索引的分区)。 “storage_optimized_l1”:支持每个分区 1TB,最多支持 12 个分区。 “storage_optimized_l2”:支持每个分区 2TB,最多支持 12 个分区。
|
SkuName
枚举
搜索服务的 SKU。 有效值包括:“free”:共享服务。 “basic”:最多包含 3 个副本的专用服务。 “standard”:最多包含 12 个分区和 12 个副本的专用服务。 “standard2”:类似于标准,但每个搜索单位的容量更多。 “standard3”:最大标准产品/服务最多包含 12 个分区和 12 个副本(如果同时将 hostingMode 属性设置为“highDensity”,则最多具有 3 个具有更多索引的分区)。 “storage_optimized_l1”:支持每个分区 1TB,最多支持 12 个分区。 “storage_optimized_l2”:支持每个分区 2TB,最多支持 12 个分区。
| 值 |
说明 |
|
free
|
免费层,没有 SLA 保证,以及可计费层上提供的功能子集。
|
|
basic
|
专用服务的计费层最多包含 3 个副本。
|
|
standard
|
专用服务的计费层最多包含 12 个分区和 12 个副本。
|
|
standard2
|
类似于“标准”,但每个搜索单位的容量更多。
|
|
standard3
|
最大标准产品/服务最多包含 12 个分区和 12 个副本(如果同时将 hostingMode 属性设置为“highDensity”,则最多包含 3 个具有更多索引的分区)。
|
|
storage_optimized_l1
|
专用服务的计费层支持每个分区 1TB,最多支持 12 个分区。
|
|
storage_optimized_l2
|
专用服务的计费层支持每个分区 2TB,最多支持 12 个分区。
|
systemData
Object
与创建和上次修改资源相关的元数据。
| 名称 |
类型 |
说明 |
|
createdAt
|
string
(date-time)
|
资源创建时间戳(UTC)。
|
|
createdBy
|
string
|
创建资源的标识。
|
|
createdByType
|
createdByType
|
创建资源的标识的类型。
|
|
lastModifiedAt
|
string
(date-time)
|
上次修改的资源时间戳(UTC)
|
|
lastModifiedBy
|
string
|
上次修改资源的标识。
|
|
lastModifiedByType
|
createdByType
|
上次修改资源的标识的类型。
|
UpgradeAvailable
枚举
指示搜索服务是否有可用的升级。
| 值 |
说明 |
|
notAvailable
|
升级目前不适用于该服务。
|
|
available
|
有一个升级可用于该服务。
|
UserAssignedIdentity
Object
用户分配的标识属性
| 名称 |
类型 |
说明 |
|
clientId
|
string
(uuid)
|
分配的标识的客户端 ID。
|
|
principalId
|
string
(uuid)
|
已分配标识的主体 ID。
|