{
  "useCase": "collab/guest-documents-storage",
  "version": "v1",
  "purpose": "The documents your guests sign.",
  "resourceKind": "BlobContainer",
  "role": {
    "name": "Storage Blob Data Contributor",
    "id": "ba92f5b4-2d11-453d-a403-e96b0029c9fe",
    "scope": "container",
    "scopeId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"
  },
  "requiredActions": [
    "Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read",
    "Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write"
  ],
  "whoMayConnect": {
    "roles": [
      "Owner",
      "User Access Administrator",
      "Role Based Access Control Administrator"
    ],
    "action": "Microsoft.Authorization/roleAssignments/write"
  },
  "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": {
    "create.ps1": {
      "action": "create",
      "shell": "PowerShell 7 or Windows PowerShell 5.1",
      "modules": [
        "Az.Accounts",
        "Az.Resources",
        "Az.Storage"
      ],
      "parameters": {
        "accountName": {
          "powershell": "-AccountName",
          "cli": "--account-name",
          "required": true,
          "description": "The storage account: 3 to 24 lowercase letters and digits, unique in Azure."
        },
        "containerName": {
          "powershell": "-ContainerName",
          "cli": "--container-name",
          "required": true,
          "description": "The container: 3 to 63 lowercase letters, digits and hyphens, starting and ending with a letter or digit, with no two hyphens in a row."
        },
        "region": {
          "powershell": "-Region",
          "cli": "--region",
          "required": true,
          "description": "The Azure region of a new resource, for example westeurope. In the template it defaults to the region of the resource group."
        },
        "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."
        },
        "resourceGroup": {
          "powershell": "-ResourceGroupName",
          "cli": "--resource-group",
          "required": false,
          "default": "rg-easylife365",
          "description": "The resource group of a new resource. Created in the region when it is missing."
        },
        "subscription": {
          "powershell": "-Subscription",
          "cli": "--subscription",
          "required": false,
          "description": "The subscription ID or name. Without it the script uses the current subscription and asks you to confirm it."
        },
        "yes": {
          "powershell": "-Yes",
          "cli": "--yes",
          "required": false,
          "description": "A switch with no value: uses the current subscription without asking."
        }
      },
      "creates": [
        "Resource group, when the storage account and the group don't exist yet",
        "Storage account: StorageV2, Standard_LRS, access tier Hot, TLS 1.2, HTTPS only, no shared key access, no anonymous blob access, no cross-tenant replication",
        "Blob container with no anonymous access",
        "Role assignment: Storage Blob Data Contributor for the service principal of the app, at the container"
      ],
      "runAs": "Owner, or Contributor together with User Access Administrator or Role Based Access Control Administrator, on the subscription"
    },
    "create.sh": {
      "action": "create",
      "shell": "Bash with the Azure CLI",
      "parameters": {
        "accountName": {
          "powershell": "-AccountName",
          "cli": "--account-name",
          "required": true,
          "description": "The storage account: 3 to 24 lowercase letters and digits, unique in Azure."
        },
        "containerName": {
          "powershell": "-ContainerName",
          "cli": "--container-name",
          "required": true,
          "description": "The container: 3 to 63 lowercase letters, digits and hyphens, starting and ending with a letter or digit, with no two hyphens in a row."
        },
        "region": {
          "powershell": "-Region",
          "cli": "--region",
          "required": true,
          "description": "The Azure region of a new resource, for example westeurope. In the template it defaults to the region of the resource group."
        },
        "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."
        },
        "resourceGroup": {
          "powershell": "-ResourceGroupName",
          "cli": "--resource-group",
          "required": false,
          "default": "rg-easylife365",
          "description": "The resource group of a new resource. Created in the region when it is missing."
        },
        "subscription": {
          "powershell": "-Subscription",
          "cli": "--subscription",
          "required": false,
          "description": "The subscription ID or name. Without it the script uses the current subscription and asks you to confirm it."
        },
        "yes": {
          "powershell": "-Yes",
          "cli": "--yes",
          "required": false,
          "description": "A switch with no value: uses the current subscription without asking."
        }
      },
      "creates": [
        "Resource group, when the storage account and the group don't exist yet",
        "Storage account: StorageV2, Standard_LRS, access tier Hot, TLS 1.2, HTTPS only, no shared key access, no anonymous blob access, no cross-tenant replication",
        "Blob container with no anonymous access",
        "Role assignment: Storage Blob Data Contributor for the service principal of the app, at the container"
      ],
      "runAs": "Owner, or Contributor together with User Access Administrator or Role Based Access Control Administrator, on the subscription"
    },
    "template.json": {
      "action": "template",
      "source": "template.bicep",
      "deployToAzure": "https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fdocs.easylife365.cloud%2Fdownloads%2Fcollab%2Fguest-documents-storage%2Fv1%2Ftemplate.json",
      "parameters": {
        "accountName": "The storage account: 3 to 24 lowercase letters and digits, unique in Azure.",
        "containerName": "The container: 3 to 63 lowercase letters, digits and hyphens, starting and ending with a letter or digit, with no two hyphens in a row.",
        "region": "The Azure region. Default: the region of the resource group."
      },
      "creates": [
        "Storage account: StorageV2, Standard_LRS, access tier Hot, TLS 1.2, HTTPS only, no shared key access, no anonymous blob access, no cross-tenant replication",
        "Blob container with no anonymous access"
      ],
      "access": "None. Run grant.ps1 or grant.sh afterwards.",
      "runAs": "Contributor or Owner on the resource group"
    },
    "grant.ps1": {
      "action": "grant",
      "shell": "PowerShell 7 or Windows PowerShell 5.1",
      "modules": [
        "Az.Accounts",
        "Az.Resources",
        "Az.Storage"
      ],
      "parameters": {
        "accountName": {
          "powershell": "-AccountName",
          "cli": "--account-name",
          "required": true,
          "description": "The storage account: 3 to 24 lowercase letters and digits, unique in Azure."
        },
        "containerName": {
          "powershell": "-ContainerName",
          "cli": "--container-name",
          "required": true,
          "description": "The container: 3 to 63 lowercase letters, digits and hyphens, starting and ending with a letter or digit, with no two hyphens in a row."
        },
        "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: Storage Blob Data Contributor for the service principal of the app, at the container"
      ],
      "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": {
        "accountName": {
          "powershell": "-AccountName",
          "cli": "--account-name",
          "required": true,
          "description": "The storage account: 3 to 24 lowercase letters and digits, unique in Azure."
        },
        "containerName": {
          "powershell": "-ContainerName",
          "cli": "--container-name",
          "required": true,
          "description": "The container: 3 to 63 lowercase letters, digits and hyphens, starting and ending with a letter or digit, with no two hyphens in a row."
        },
        "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: Storage Blob Data Contributor for the service principal of the app, at the container"
      ],
      "runAs": "Owner, User Access Administrator, Role Based Access Control Administrator, at the scope of the role or above"
    }
  }
}
