def create_search_service(cmd, resource_group_name, search_service_name, sku, location=None, partition_count=0, replica_count=0,): """ Creates a Search service in the given resource group. :param resource_group_name: Name of resource group. :param search_service_name: Name of the search service. :param sku: The SKU of the search service, which determines price tier and capacity limits. :param location: Geographic location of the resource. :param partition_count: Number of partitions in the search service. :param replica_count: Number of replicas in the search service. """ from azure.mgmt.search.models import SearchService, Sku from azure.cli.command_modules.search._client_factory import cf_search_services _client = cf_search_services(cmd.cli_ctx, None) if location is None: location = _get_resource_group_location(cmd.cli_ctx, resource_group_name) _search = SearchService(location=location, sku=Sku(name=sku)) replica_count = int(replica_count) partition_count = int(partition_count) if replica_count > 0: _search.replica_count = replica_count if partition_count > 0: _search.partition_count = partition_count return _client.create_or_update(resource_group_name, search_service_name, _search)
def create_search_service(cmd, resource_group_name, search_service_name, sku, location=None, partition_count=0, replica_count=0, public_network_access="enabled", ip_rules=None, identity_type=None): """ Creates a Search service in the given resource group. :param resource_group_name: Name of resource group. :param search_service_name: Name of the search service. :param sku: The SKU of the search service, which determines price tier and capacity limits. :param location: Geographic location of the resource. :param partition_count: Number of partitions in the search service. :param replica_count: Number of replicas in the search service. :param public_network_access: Public accessibility to the search service; allowed values are "enabled" or "disabled". :param ip_rules: Public IP(v4) addresses or CIDR ranges to the search service, seperated by comma or semicolon; These IP rules are applicable only when public_network_access is "enabled". :param identity_type: The identity type; possible values include: "None", "SystemAssigned". """ from azure.mgmt.search.models import SearchService, Sku, NetworkRuleSet, IpRule, Identity from azure.cli.command_modules.search._client_factory import cf_search_services import re _client = cf_search_services(cmd.cli_ctx, None) if location is None: location = _get_resource_group_location(cmd.cli_ctx, resource_group_name) _search = SearchService(location=location, sku=Sku(name=sku.lower())) replica_count = int(replica_count) partition_count = int(partition_count) if replica_count > 0: _search.replica_count = replica_count if partition_count > 0: _search.partition_count = partition_count if (public_network_access.lower() not in ["enabled", "disabled"]): raise ValueError("SearchService.PublicNetworkAccess: only [" "enabled" ", " "disabled" "] are allowed") _search.public_network_access = public_network_access if ip_rules: _ip_rules = [] _ip_rules_array = re.split(';|,', ip_rules) for _ip_rule in _ip_rules_array: if _ip_rule: _ip_rules.append(IpRule(value=_ip_rule)) _search.network_rule_set = NetworkRuleSet(ip_rules=_ip_rules) if identity_type: _identity = Identity(type=identity_type) _search.identity = _identity return _client.begin_create_or_update(resource_group_name, search_service_name, _search)