|
| 1 | +============= |
| 2 | +Cloud Storage |
| 3 | +============= |
| 4 | + |
| 5 | +The cloud storage integration allows to store :doc:`chatter <../../productivity/discuss/chatter>` |
| 6 | +and email attachments on the :ref:`Google Cloud <cloud-storage/google>` or :ref:`Microsoft Azure |
| 7 | +<cloud-storage/microsoft>` platform instead of the database's server. |
| 8 | + |
| 9 | +The module can be used to prevent large files from being uploaded to and downloaded from a |
| 10 | +database's server or when a database requires more data storage. |
| 11 | + |
| 12 | +.. note:: |
| 13 | + - Files generated by Odoo (e.g., sales orders) and Documents/Sign app files are always stored on |
| 14 | + the database's server. |
| 15 | + - A database's storage limit depends on its hosting solution: |
| 16 | + |
| 17 | + - Odoo Online: 100 GB |
| 18 | + - Odoo.sh: |
| 19 | + |
| 20 | + - Shared hosting: 512 GB |
| 21 | + - Dedicated hosting: 4 TB |
| 22 | + |
| 23 | + - On-premise: limited by the infrastructure in place. |
| 24 | + |
| 25 | +.. _cloud-storage/google: |
| 26 | + |
| 27 | +Google Cloud |
| 28 | +============ |
| 29 | + |
| 30 | +First, register and sign in to `Google Cloud <https://cloud.google.com>`_. |
| 31 | + |
| 32 | +.. _cloud-storage/google/service: |
| 33 | + |
| 34 | +Service account |
| 35 | +--------------- |
| 36 | + |
| 37 | +#. Open the navigation sidebar on the Google Cloud console, then go to :menuselection:`IAM & Admin |
| 38 | + --> Service Accounts --> Create service account`. |
| 39 | +#. Define a :guilabel:`Service account name`, click :guilabel:`Create and continue`, then |
| 40 | + :guilabel:`Done`. |
| 41 | + |
| 42 | + .. image:: cloud_storage/service-account.png |
| 43 | + :alt: Creating a Google Cloud service account |
| 44 | + |
| 45 | +#. Note down the service account's :guilabel:`Email` as it will be used during the :ref:`cloud |
| 46 | + storage bucket configuration <cloud-storage/google/bucket>`. |
| 47 | +#. Click the :icon:`fa-ellipsis-v` (:guilabel:`Actions`) button, then select :guilabel:`Manage |
| 48 | + keys`. |
| 49 | + |
| 50 | + .. image:: cloud_storage/manage-keys.png |
| 51 | + :alt: Accessing the "Manage keys" action |
| 52 | + |
| 53 | +#. Go to :menuselection:`Add key --> Create new key`, select :guilabel:`JSON` as the :guilabel:`Key |
| 54 | + type`, and click :guilabel:`Create`. Store the downloaded JSON file containing the key securely. |
| 55 | + It will be used when :ref:`configuring Odoo <cloud-storage/google/odoo>`. |
| 56 | + |
| 57 | + .. image:: cloud_storage/create-key.png |
| 58 | + :alt: Creating a Google Cloud service account's JSON key |
| 59 | + |
| 60 | +.. _cloud-storage/google/bucket: |
| 61 | + |
| 62 | +Cloud storage bucket |
| 63 | +-------------------- |
| 64 | + |
| 65 | +#. Open the navigation sidebar on the Google Cloud console, then go to :menuselection:`Cloud |
| 66 | + Storage --> Buckets --> Create`. |
| 67 | +#. Enter a bucket name following the `bucket naming guidelines <https://cloud.google.com/storage/docs/buckets?_gl=1*h4hwrv*_ga*MTcwNDM2NDE1Ny4xNzQzNzUxOTEy*_ga_WH2QY8WWF5*MTc0Mzc2NDMyOS4zLjEuMTc0Mzc2NDMyOS42MC4wLjA.#naming>`_ |
| 68 | + and note it down as it will be used when :ref:`configuring Odoo <cloud-storage/google/odoo>`. |
| 69 | +#. Configure the bucket as desired and click :guilabel:`Create` when done. |
| 70 | + |
| 71 | + .. image:: cloud_storage/create-bucket.png |
| 72 | + :alt: Creating a bucket |
| 73 | + |
| 74 | +#. Click the :icon:`fa-ellipsis-v` (:guilabel:`More actions`) button, then select :guilabel:`Edit |
| 75 | + access`. |
| 76 | + |
| 77 | + .. image:: cloud_storage/bucket-actions.png |
| 78 | + :alt: Accessing the "Edit access" action of a Google Cloud storage bucket |
| 79 | + |
| 80 | +#. Click :guilabel:`Add principal` and paste the service account's email in the :guilabel:`New |
| 81 | + principals` field. |
| 82 | +#. Select :guilabel:`Storage Admin` as :guilabel:`Role` under the :guilabel:`Cloud Storage` section |
| 83 | + and click :guilabel:`Save`. |
| 84 | + |
| 85 | + .. image:: cloud_storage/bucket-access.png |
| 86 | + :alt: Adding a principal to a Google Cloud storage bucket |
| 87 | + |
| 88 | +.. _cloud-storage/google/odoo: |
| 89 | + |
| 90 | +Odoo configuration |
| 91 | +------------------ |
| 92 | + |
| 93 | +#. :ref:`Install <general/install>` the :guilabel:`Cloud Storage Google` module. |
| 94 | +#. Open the :guilabel:`Settings` app and select :guilabel:`Cloud Storage` in the navigation sidebar. |
| 95 | +#. Select :guilabel:`Google Cloud Storage` as the :guilabel:`Cloud Storage Provider for new |
| 96 | + attachments`. |
| 97 | +#. Enter the :guilabel:`Google Bucket Name` as :ref:`previously set <cloud-storage/google/bucket>`. |
| 98 | +#. Click :guilabel:`Upload your file` next to :guilabel:`Google Service Account Key` and select the |
| 99 | + :ref:`downloaded JSON file <cloud-storage/google/service>`. |
| 100 | +#. Set a :guilabel:`Minimum File Size (bytes)` for attachments to be stored on Google Cloud. |
| 101 | + |
| 102 | +.. _cloud-storage/microsoft: |
| 103 | + |
| 104 | +Microsoft Azure |
| 105 | +=============== |
| 106 | + |
| 107 | +First, register and sign it to `Microsoft Azure <https://azure.microsoft.com>`_. |
| 108 | + |
| 109 | +.. _cloud-storage/microsoft/app: |
| 110 | + |
| 111 | +App registration |
| 112 | +---------------- |
| 113 | + |
| 114 | +#. On the Microsoft Azure portal, search for the :guilabel:`App registrations` service and open it. |
| 115 | +#. Click :guilabel:`New registration`, enter an application :guilabel:`Name`, select |
| 116 | + :guilabel:`Accounts in any organizational directory (Any Microsoft Entra ID tenant - |
| 117 | + Multitenant)` under :guilabel:`Supported account types`, and click :guilabel:`Register`. |
| 118 | + |
| 119 | + .. image:: cloud_storage/app-registration.png |
| 120 | + :alt: Registering a Microsoft Azure app |
| 121 | + |
| 122 | +#. Note down the :guilabel:`Application (client) ID` and :guilabel:`Directory (tenant) ID` as they |
| 123 | + will be used when :ref:`configuring Odoo <cloud-storage/microsoft/odoo>`. |
| 124 | +#. Click :guilabel:`Add a certificate or secret` next to :guilabel:`Client credentials`, click |
| 125 | + :guilabel:`New client secret`, then :guilabel:`Add`. |
| 126 | + |
| 127 | +.. important:: |
| 128 | + For security reasons, leave the :guilabel:`Expires` field on `180 days (6 months)` or choose a |
| 129 | + shorter expiration interval. Before the secret expires, adding a new client secret and updating |
| 130 | + :ref:`Odoo’s configuration <cloud-storage/microsoft/odoo>` with the new value is necessary. |
| 131 | + |
| 132 | +#. Copy the client secret's :guilabel:`Value` and store it securely. It will be used when |
| 133 | + :ref:`configuring Odoo <cloud-storage/microsoft/odoo>`. |
| 134 | + |
| 135 | + .. image:: cloud_storage/app-client-secret.png |
| 136 | + :alt: Adding a secret to a Microsoft Azure app |
| 137 | + |
| 138 | +.. _cloud-storage/microsoft/storage: |
| 139 | + |
| 140 | +Storage account |
| 141 | +--------------- |
| 142 | + |
| 143 | +#. Search for the :guilabel:`Storage accounts` service, open it, and click :guilabel:`Create`. |
| 144 | +#. Click :guilabel:`Create new` below the :guilabel:`Resource group` field, enter a |
| 145 | + :guilabel:`Name`, and click :guilabel:`OK`. |
| 146 | +#. Enter a unique :guilabel:`Storage account name` and note it down as it will be used when |
| 147 | + :ref:`configuring Odoo <cloud-storage/microsoft/odoo>`. |
| 148 | +#. Configure the storage account as desired, and, when done, click :guilabel:`Review + create`, then |
| 149 | + :guilabel:`Create`. |
| 150 | + |
| 151 | + .. image:: cloud_storage/storage-account.png |
| 152 | + :alt: Creating a Microsoft Azure storage account |
| 153 | + |
| 154 | +.. _cloud-storage/microsoft/container: |
| 155 | + |
| 156 | +Container |
| 157 | +~~~~~~~~~ |
| 158 | + |
| 159 | +#. Open your storage account resource, for example by searching for its name, and select |
| 160 | + :guilabel:`Containers` under :guilabel:`Data storage` in the navigation sidebar. |
| 161 | +#. Enter a :guilabel:`Name`, note it down as it will be used when :ref:`configuring Odoo |
| 162 | + <cloud-storage/microsoft/odoo>`, and click :guilabel:`Create`. |
| 163 | + |
| 164 | + .. image:: cloud_storage/storage-account-container.png |
| 165 | + :alt: Creating a Microsoft Azure storage container |
| 166 | + |
| 167 | +.. _cloud-storage/microsoft/resource: |
| 168 | + |
| 169 | +Resource sharing |
| 170 | +~~~~~~~~~~~~~~~~ |
| 171 | + |
| 172 | +#. Select :guilabel:`Resource sharing (CORS)` under :guilabel:`Settings` on the storage account's |
| 173 | + navigation sidebar. |
| 174 | +#. Create a first CORS blob service rule: |
| 175 | + |
| 176 | + - :guilabel:`Allowed origins`: `*` |
| 177 | + - :guilabel:`Allowed methods`: `GET` |
| 178 | + - :guilabel:`Allowed headers`: `Content-Type` |
| 179 | + - :guilabel:`Exposed headers`: `Content-Type` |
| 180 | + - :guilabel:`Max age`: `0` |
| 181 | + |
| 182 | +#. Create a second CORS blob service rule and click :guilabel:`Save`: |
| 183 | + |
| 184 | + - :guilabel:`Allowed origins`: `*` |
| 185 | + - :guilabel:`Allowed methods`: `PUT` |
| 186 | + - :guilabel:`Allowed headers`: `content-type,x-ms-blob-type` |
| 187 | + - :guilabel:`Exposed headers`: `content-type,x-ms-blob-type` |
| 188 | + - :guilabel:`Max age`: `0` |
| 189 | + |
| 190 | + .. image:: cloud_storage/resource-sharing.png |
| 191 | + :alt: Creating Microsoft Azure storage account CORS rules |
| 192 | + |
| 193 | +.. _cloud-storage/microsoft/role: |
| 194 | + |
| 195 | +Role assignment |
| 196 | +~~~~~~~~~~~~~~~ |
| 197 | + |
| 198 | +#. Select :guilabel:`Access control (IAM)` on the storage account's navigation sidebar, then click |
| 199 | + :guilabel:`Add` and select :guilabel:`Add role assignment`. |
| 200 | +#. Search for :guilabel:`Storage Blobs Data Contributor` and click :guilabel:`Next`. |
| 201 | + |
| 202 | + .. note:: |
| 203 | + To remove the unnecessary `delete` permission, create a :ref:`custom role |
| 204 | + <cloud-storage/microsoft/custom>` and search for the custom role's name instead. |
| 205 | + |
| 206 | +#. Click :guilabel:`Select members`, enter the name of the :ref:`previously registered application |
| 207 | + <cloud-storage/microsoft/app>`, select it, and click :guilabel:`Select`. |
| 208 | +#. Click :guilabel:`Review + assign` twice. |
| 209 | + |
| 210 | + .. image:: cloud_storage/storage-account-role.png |
| 211 | + :alt: Adding a member to a container |
| 212 | + |
| 213 | +.. _cloud-storage/microsoft/custom: |
| 214 | + |
| 215 | +Custom role |
| 216 | +*********** |
| 217 | + |
| 218 | +.. note:: |
| 219 | + This step is **optional**. However, removing the `delete` permission would prevent anyone |
| 220 | + managing to access the cloud storage's credentials from deleting files. |
| 221 | + |
| 222 | +#. Open your subscription resource, for example by searching for its name, select :guilabel:`Access |
| 223 | + control (IAM)` in the navigation sidebar, click :guilabel:`Add` and select :guilabel:`Add custom |
| 224 | + role`. |
| 225 | +#. Select the :guilabel:`JSON` tab and click :guilabel:`Edit`. Copy the code below, add your |
| 226 | + `subscription-id` under `assignableScopes` and change the `roleName` (`Custom role`) if desired, |
| 227 | + paste it, and click :guilabel:`Save`. |
| 228 | + |
| 229 | +.. code-block:: json |
| 230 | +
|
| 231 | + { |
| 232 | + "properties": { |
| 233 | + "roleName": "Custom role", |
| 234 | + "description": "", |
| 235 | + "assignableScopes": [ |
| 236 | + "/subscriptions/subscription-id" |
| 237 | + ], |
| 238 | + "permissions": [ |
| 239 | + { |
| 240 | + "actions": ["Microsoft.Storage/storageAccounts/blobServices/generateUserDelegationKey/action"], |
| 241 | + "notActions": [], |
| 242 | + "dataActions": ["Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read", "Microsoft.Storage/storageAccounts/blobServices/containers/blobs/add/action"], |
| 243 | + "notDataActions": [] |
| 244 | + } |
| 245 | + ] |
| 246 | + } |
| 247 | + } |
| 248 | +
|
| 249 | +.. _cloud-storage/microsoft/odoo: |
| 250 | + |
| 251 | +Odoo configuration |
| 252 | +------------------ |
| 253 | + |
| 254 | +#. :ref:`Install <general/install>` the :guilabel:`Cloud Storage Azure` module. |
| 255 | +#. Open the :guilabel:`Settings` app and select :guilabel:`Cloud Storage` in the navigation sidebar. |
| 256 | +#. Select :guilabel:`Azure Cloud Azure` as the :guilabel:`Cloud Storage Provider for new |
| 257 | + attachments`. |
| 258 | +#. Enter: |
| 259 | + |
| 260 | + - the :ref:`storage account name <cloud-storage/microsoft/storage>` in the :guilabel:`Azure |
| 261 | + Account Name` field; |
| 262 | + - the :ref:`container name <cloud-storage/microsoft/container>` in the :guilabel:`Azure Container |
| 263 | + Name` field; |
| 264 | + - the :ref:`directory (tenant) ID <cloud-storage/microsoft/app>` in the :guilabel:`Azure Tenant |
| 265 | + ID` field; |
| 266 | + - the :ref:`application (client) ID <cloud-storage/microsoft/app>` in the :guilabel:`Azure Client |
| 267 | + ID` field; and |
| 268 | + - the :ref:`client secret's value <cloud-storage/microsoft/app>` in the :guilabel:`Azure Client |
| 269 | + Secret` field. |
| 270 | + |
| 271 | +#. Set a :guilabel:`Minimum File Size (bytes)` for attachments to be stored on Microsoft Azure. |
0 commit comments