azure-storagekeystonejs

How can I use Azure Storage Account with Keystone?


I have an app that I need to move to an Azure subcription. the stack is NextJs, Prisma and Keystone.

It is doing some file uploading and Keystone have built in support for s3 storage.

Is there a way to use a Azure Storage account in place of an s3?

I tried using this https://www.npmjs.com/package/@k6-contrib/fields-azure but can't get it to work.


Solution

  • I got help from another source and managed to solve it.

    I used the package (https://www.npmjs.com/package/@k6-contrib/fields-azure) but had to make some modifications.

    In keystone.ts

    Add import

    import {AzureStorageConfig, azureStorageImage} from "@k6-contrib/fields-azure";
    

    Then a config object needs to be created for the SA-connection.

    const azConfig: AzureStorageConfig = {
        azureStorageOptions: {
            account: process.env.AZURE_STORAGE_ACCOUNT_NAME || '',
            accessKey: process.env.AZURE_STORAGE_ACCESS_KEY || '',
            container: process.env.AZURE_STORAGE_CONTAINER || '',
            url: process.env.AZURE_STORAGE_ACCOUNT_HOST
                ? `${process.env.AZURE_STORAGE_ACCOUNT_HOST}${process.env.AZURE_STORAGE_CONTAINER}`
                : undefined,
        },
    };
    

    Note that this differs somewhat from the instructions at npm and in the example. The url needed to be "host/container".

    Then the fields connected to the storage needed to be set. In my case the "logo" field.

    logo: azureStorageImage({azureStorageConfig: azConfig})
    

    Hope this can help someone out there with a similar problem.