Azure / Azure/azure-cli

[Azure AI Search] az search service create --sku serverless always fails: CLI sends replicaCount/partitionCount which serverless rejects (HTTP 400)

Open
#33,514 3 comments 0 reactions 1 assignee Claimed by @mattgotteiner View on GitHub
Language Search Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

`az search service create --sku serverless` can never create a service. `serverless` is a valid value in the command's own `--sku` enum, but the command always emits an ARM PUT containing `properties.replicaCount` and `properties.partitionCount` (both defaulted to 1). The serverless SKU rejects `replicaCount` with HTTP 400, so the create fails every time and nothing is provisioned. There is no flag that suppresses those properties (you cannot pass a count of 0), so the failure is unconditional.

A hand-written ARM PUT, or a Bicep deployment, that omits those two properties creates the same serverless service successfully. That shows the fault is in the request body the CLI builds, not in the service.

### Related command

`az search service create`

### To Reproduce

Run the command with only the required arguments (no replica or partition flags):

```
az search service create -n -g -l westcentralus --sku serverless
```

### Actual behavior

The CLI builds and sends this ARM request:

```http
PUT https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Search/searchServices/?api-version=2026-03-01-preview
Content-Type: application/json

{
"location": "westcentralus",
"properties": {
"hostingMode": "default",
"partitionCount": 1,
"publicNetworkAccess": "enabled",
"replicaCount": 1
},
"sku": { "name": "serverless" }
}
```

`partitionCount` and `replicaCount` are injected by the CLI even though they were never supplied on the command line, and neither is valid for the serverless SKU. ARM returns 400 and no service is created:

```json
{"error":{"code":"BadRequest","message":"The 'replicaCount' property is not applicable to the 'serverless' SKU."}}
```

### Expected behavior

For the serverless SKU, the CLI should omit `replicaCount`, `partitionCount`, and `hostingMode` from the request body, matching what ARM and Bicep accept. The minimal request succeeds and the service provisions:

```http
PUT .../searchServices/?api-version=2026-03-01-preview
Content-Type: application/json

{ "location": "westcentralus", "sku": { "name": "serverless" } }
```

A service created this way returns `replicaCount` and `partitionCount` as null, which is the expected serverless shape.

### Environment summary

- azure-cli 2.87.0
- OS: Windows
- `az search service create` (GA)

### Additional context

The create command is AAZ-generated and serializes both properties unconditionally from arguments that default to 1, in `src/azure-cli/azure/cli/command_modules/search/aaz/latest/search/service/_create.py`:

```python
properties.set_prop("partitionCount", AAZIntType, ".partition_count")
properties.set_prop("replicaCount", AAZIntType, ".replica_count")
```

A serverless-aware fix would skip these properties (and `hostingMode`) when `--sku serverless` is used. Bicep already special-cases this.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.