@nx/powerpack-azure-cache

The @nx/powerpack-azure-cache plugin enables you to use Azure Storage instead of Nx Cloud to host your remote cache.

This plugin will enable the remote cache for your Nx workspace, but does not provide any of the other features of Nx Cloud. If you want to leverage distributed task execution, re-running flaky tasks or automatically splitting tasks, you'll need to connect to Nx Cloud and use Nx Replay instead.

Potential Cache Poisoning

Using your own Azure Storage account to host the remote cache opens you up to the possibility of cache poisoning. To avoid this, use Nx Replay.

This plugin requires an active Nx Powerpack license

In order to use @nx/powerpack-azure-cache, you need to have an active Powerpack license. If you don't have a license or it has expired, your cache will no longer be shared and each machine will use its local cache.

Set Up @nx/powerpack-azure-cache

1. Install the Package

  1. Activate Powerpack if you haven't already
  2. Install the package

โฏ

nx add @nx/powerpack-azure-cache

2. Authenticate with Azure

There are several ways to authenticate with Azure Storage, but the method recommended by Azure is to use OpenID Connect, like this:

.github/workflows/ci.yml
1name: CI 2... 3permissions: 4 id-token: write 5 ... 6 7jobs: 8 main: 9 env: 10 NX_POWERPACK_LICENSE: ${{ secrets.NX_POWERPACK_LICENSE }} 11 runs-on: ubuntu-latest 12 steps: 13 ... 14 15 - name: Azure login 16 uses: azure/login@v2 17 with: 18 client-id: ${{ secrets.AZURE_CLIENT_ID }} 19 tenant-id: ${{ secrets.AZURE_TENANT_ID }} 20 subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} 21 ... 22 23 - run: pnpm exec nx affected -t lint test build 24

You need to set the AZURE_CLIENT_ID, AZURE_TENANT_ID and AZURE_SUBSCRIPTION_ID secrets as defined in the Azure documentation.

Note: Any authentication method that sets up the DefaultAzureCredentials will enable the plugin to work.

Custom Azure Endpoint

If you are using a custom Azure endpoint, you will need to authenticate by setting the AZURE_STORAGE_CONNECTION_STRING environment variable. The @nx/powerpack-azure-cache plugin will detect the environment variable and automatically use it to connect to Azure.

3. Configure the Nx Cache to Use Azure Storage

Finally, you need to configure your Nx cache in the nx.json file. The container that you specify needs to already exist - Nx doesn't create it for you.

nx.json
1{ 2 "azure": { 3 "container": "mycontainer", 4 "accountName": "myaccount" 5 } 6} 7
PropertyDescription
containerThe name of the container to use
accountNameThe name of blob storage account

Package reference

Here is a list of all the executors and generators available from this package.

Guides

Executors

Generators