{
  "useCase": "identity/credential-renewal-certificate",
  "version": "v1",
  "purpose": "A certificate that EasyLife 365 renews in your key vault. There is no create script and no template: this use case gives access only.",
  "resourceKind": "KeyVaultCertificate",
  "role": {
    "name": "Key Vault Certificates Officer",
    "id": "a4417e6f-fecd-4de8-b567-7b0420556985",
    "scope": "vault",
    "scopeId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.KeyVault/vaults/{vaultName}",
    "note": "EasyLife 365 checks the certificate role at the vault, so the role is on the vault and covers every certificate in it: the app can do anything with any of them, including deleting one for good, and can manage the certificate issuers of the vault."
  },
  "requiredActions": [
    "Microsoft.KeyVault/vaults/certificates/read",
    "Microsoft.KeyVault/vaults/certificates/create/action"
  ],
  "whoMayConnect": {
    "roles": [
      "Owner",
      "User Access Administrator",
      "Role Based Access Control Administrator"
    ],
    "action": "Microsoft.Authorization/roleAssignments/write"
  },
  "stopsWhen": "The key vault uses access policies (enableRbacAuthorization is not true). The script stops and changes nothing on that vault.",
  "rules": [
    "Parameters only, no other input",
    "Running a script again changes nothing that exists and lists it as skipped",
    "Never deletes anything and never changes the settings of an existing resource"
  ],
  "files": {
    "grant.ps1": {
      "action": "grant",
      "shell": "PowerShell 7 or Windows PowerShell 5.1",
      "modules": [
        "Az.Accounts",
        "Az.Resources"
      ],
      "parameters": {
        "vaultName": {
          "powershell": "-VaultName",
          "cli": "--vault-name",
          "required": true,
          "description": "The key vault: 3 to 24 letters, digits and hyphens, starting with a letter, ending with a letter or digit, with no two hyphens in a row. Unique in Azure."
        },
        "certificateName": {
          "powershell": "-CertificateName",
          "cli": "--certificate-name",
          "required": true,
          "description": "The certificate: 1 to 127 letters, digits and hyphens. It may start with a hyphen. The script checks and shows the name only: the role is on the vault."
        },
        "appId": {
          "powershell": "-AppId",
          "cli": "--app-id",
          "required": true,
          "description": "The application (client) ID of the EasyLife 365 app in your tenant. The role goes to the service principal of this app."
        },
        "subscription": {
          "powershell": "-Subscription",
          "cli": "--subscription",
          "required": false,
          "description": "The subscription ID or name. Default: the current subscription."
        }
      },
      "creates": [
        "Role assignment: Key Vault Certificates Officer for the service principal of the app, at the vault"
      ],
      "runAs": "Owner, User Access Administrator, Role Based Access Control Administrator, at the scope of the role or above"
    },
    "grant.sh": {
      "action": "grant",
      "shell": "Bash with the Azure CLI",
      "parameters": {
        "vaultName": {
          "powershell": "-VaultName",
          "cli": "--vault-name",
          "required": true,
          "description": "The key vault: 3 to 24 letters, digits and hyphens, starting with a letter, ending with a letter or digit, with no two hyphens in a row. Unique in Azure."
        },
        "certificateName": {
          "powershell": "-CertificateName",
          "cli": "--certificate-name",
          "required": true,
          "description": "The certificate: 1 to 127 letters, digits and hyphens. It may start with a hyphen. The script checks and shows the name only: the role is on the vault."
        },
        "appId": {
          "powershell": "-AppId",
          "cli": "--app-id",
          "required": true,
          "description": "The application (client) ID of the EasyLife 365 app in your tenant. The role goes to the service principal of this app."
        },
        "subscription": {
          "powershell": "-Subscription",
          "cli": "--subscription",
          "required": false,
          "description": "The subscription ID or name. Default: the current subscription."
        }
      },
      "creates": [
        "Role assignment: Key Vault Certificates Officer for the service principal of the app, at the vault"
      ],
      "runAs": "Owner, User Access Administrator, Role Based Access Control Administrator, at the scope of the role or above"
    }
  }
}
