# Add role assignments to the storage account/s

Before the solution can backup your storage tables, it needs to be granted access to the storage account containing the Azure tables that you want to backup. Specifically, the system managed identity of the function app needs to be granted the **Storage Table Data Reader** and **Storage Blob Data Contributor** roles to the storage account.

The script below can do this for you. You'll need to run this against every storage account where you are backing up tables.

{% embed url="<https://github.com/SMSAgentSoftware/AzureTableBackup/blob/main/Add-AzStorageAccountRoleAssigments.ps1>" %}

Download the script and set the parameters at the top of the script:

* **Tenant** (tenant Id)
* **Subscription** (subscription name)
* **StorageAccountName** (the name of the storage account containing the tables you want to backup)

<figure><img src="https://3886807721-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWe9ieepRHnj7T8odXt%2Fuploads%2FyFqukiyVGZQwt4qB662Z%2Fimage.png?alt=media&#x26;token=df8f1bcf-9446-4f8a-929e-a09f247126ca" alt=""><figcaption></figcaption></figure>

Execute the script, and upon successful execution the new role assigments will be reported:

<figure><img src="https://3886807721-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWe9ieepRHnj7T8odXt%2Fuploads%2FHCU4sJfhR6zeU4tjB9SP%2Fimage.png?alt=media&#x26;token=15e4955d-1a60-4b8c-a20d-52323567a6ab" alt=""><figcaption></figcaption></figure>

In the storage account in the Azure portal, in the **Access Control (IAM)** blade, in the **Role assignments** tab, you will see the new role assignments added.

<figure><img src="https://3886807721-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MWe9ieepRHnj7T8odXt%2Fuploads%2Fxn9ziziK7QNvP1lOg2x9%2Fimage.png?alt=media&#x26;token=26f2c1c6-0f3e-44bd-bacb-2f14f66bc410" alt=""><figcaption></figcaption></figure>
