I've set up my Postgres flexible server in Azure to use Azure AD admins and added a service principal as the admin (nevermind the added user in the screenshot, that was just an experiment):
Now, I want the ServicePrincipal AD admin to be able to do the following via database migrations in our .NET services (using DbUp):
- Create new roles and
- GRANT permissions to the created roles
When I ran migrations to create the roles and the GRANTs, I got an error telling me that the ServicePrincipal doesn't have permissions to access public.schemaversions
Very well, then I wanted to start by granting the ServicePrincipal itself the privileges to access public.schemaversions
, like so:
ALTER SCHEMA public OWNER TO <service principal name>;
GRANT USAGE ON SCHEMA public TO <service principal name>;
GRANT SELECT, INSERT ON public.schemaversions TO <service principal name>;
psql "sslmode=require host=<server> port=<port> dbname=MyDatabase" -U <service principal name> -w
Then I get the following error:
ERROR: permission denied for database MyDatabase
GRANT: ERROR: permission denied for table schemaversions
Is there something I've missed here? Can't the Azure AD admin run GRANT
statements? It only seems like it can connect to the server and create roles.