Directus 10.10 Azure MSSQL Setup

102 views Asked by At

I try to deploy Directus 10.10 as a container app to azure, using a serverless mssql database and azure file storage for /extensions and /uploads. Both are mounted via container app volumes. The replication of the container is expected to be at 0 if there is no traffic.

On container start, the container crashes with the following log:

RequestError: ALTER TABLE [directus_extensions] ADD [id] uniqueidentifier null, [folder] nvarchar(255), [source] nvarchar(255), [bundle] uniqueidentifier - Column names in each table must be unique. Column name 'id' in table 'directus_extensions' is specified more than once.
at RequestTokenHandler.onErrorMessage (/directus/node_modules/.pnpm/[email protected]/node_modules/tedious/lib/token/handler.js:287:21)
at Readable.<anonymous> (/directus/node_modules/.pnpm/[email protected]/node_modules/tedious/lib/token/token-stream-parser.js:18:33)
at Readable.emit (node:events:517:28)
at addChunk (node:internal/streams/readable:368:12)
at readableAddChunk (node:internal/streams/readable:341:9)
at Readable.push (node:internal/streams/readable:278:10)
at next (node:internal/streams/from:98:31)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'EREQUEST',
number: 2705,
state: 4,
class: 16,
serverName: 'my-dev-db',
procName: '',
lineNumber: 1
[09:34:45.689] INFO: Skipping CLI extensions initialization due to outstanding migrations.
[09:34:45.694] INFO: Initializing bootstrap...
[09:34:45.766] INFO: Database already initialized, skipping install
[09:34:45.766] INFO: Running migrations...
[09:34:45.776] INFO: Applying Marketplace...

The database is empty at the beginning and after crash, it looks like tables are all present. Does someone know whats going on or how to debug this?

It is strange to have the log message "Databae already initialized" on an empty db?

My goal is to work with the directus SDK and fetch public available objects like FAQs, News, ... etc. Everything not very time-sensitive and cachable. To safe cost, its essential to be able to only start the container on request, not having it running indefinitely. I expect the query to be something like this:

import { createDirectus, rest, readItems } from '@directus/sdk';

const client = createDirectus('http://my-azure-instance.whatever-from-microsoft.com/api').with(rest());

const result = await client.request(
    readItems('faqs', {
        fields: ['id', 'title'],
    })
);
1

There are 1 answers

0
John Salichos On

The error states:

ALTER TABLE [directus_extensions] ADD [id] uniqueidentifier null, [folder] nvarchar(255), [source] nvarchar(255), [bundle] uniqueidentifier - Column names in each table must be unique. Column name 'id' in table 'directus_extensions' is specified more than once.

For me the solution was to table directus_extensions and then create it again:

DROP TABLE [dbo].[directus_extensions]

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[directus_extensions] (
    [name] NVARCHAR (255) NOT NULL
);

Then the migration can run smoothly!