Azure / Azure/azure-cli

Failure to create a keyvault certificate should result in a non-zero exit code

Open
#18,425 2 comments 0 reactions 1 assignee Claimed by @evelyn-ys View on GitHub
act-identity-squad feature-request KeyVault
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Describe the bug**
When creating a certificate in keyvault fails, the exit code is still 0. We have a script that relies on the detecting errors like these, but can't or has to resort to output scraping.

A recent, scrubbed example:
```sh
> az keyvault certificate create --vault-name my-kv-name -n "my-certificate" -p '{...snip}'
{
"cancellationRequested": false,
"csr": "...",
"error": {
"code": "Request rejected",
"innerError": null,
"message": ""
},
"id": "https://my-kv-name.vault.azure.net/certificates/my-certificate/pending",
"issuerParameters": {
"certificateTransparency": null,
"certificateType": null,
"name": "MyFancyIssuer"
},
"name": "my-certificate",
"requestId": "eda842e89bef458bb3634fd1f0557ed3",
"status": "failed",
"statusDetails": "Pending certificate created. Certificate request is in progress. This may take some time based on the issuer provider. Please check again later.",
"target": null
}

> echo $?
0
```

The certificate created by this command appears in the portal as 'Disabled', and is not usable.

**To Reproduce**
I don't know of a great way to reliably get `az keyvault certificate create` to fail, but see above for returned data/details.

**Expected behavior**
I'd expect a non-zero error code, indicating failure.

**Environment summary**
Installed via homebrew on bash in macOS.

```sh
> az --version
azure-cli 2.24.1 *

core 2.24.1 *
telemetry 1.0.6

Extensions:
azure-devops 0.18.0
```

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.