Hello,
I solved the problem using an Azure deployment script. I install postgresql-client in the Alpine Linux container in which the script runs.
resource createPostgresTable 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
name: 'createPostgresTable'
location: location
kind: 'AzureCLI'
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${managedIdentityId}': {}
}
}
properties: {
azCliVersion: '2.37.0'
retentionInterval: 'P1D'
environmentVariables: [
{
name: 'administratorLogin'
value: postgresDatabase.properties.administratorLogin
}
{
name: 'PGPASSWORD'
value: administratorLoginPassword
}
{
name: 'postgresDatabaseName'
value: postgresDatabase.name
}
]
cleanupPreference: 'OnSuccess'
forceUpdateTag: currentTime
scriptContent: '''
az login --identity
apk add --no-cache postgresql-client
psql \
--host=${postgresDatabaseName}.postgres.database.azure.com \
--username=$administratorLogin \
--dbname=postgres <<-EOSQL
CREATE TABLE IF NOT EXISTS public.pressure (
timestamp TIMESTAMPTZ NOT NULL,
asset_id BIGINT NOT NULL,
sensor_name VARCHAR (25) NOT NULL,
pressure REAL,
PRIMARY KEY (timestamp, asset_id)
);
EOSQL
'''
}
}