How To: Deploy Prisma service to Azure and connect to MySQL DB also hosted in Azure

prisma

#1

Hi everyone!

I’m very new to backend so Prisma was a really great starting point for me. I’m now looking at deploying my backend to Azure with some help from my boss. I’ve managed to deploy my TS NodeJS project (based off the simple Node TS starter) and it’s working. I’ve also created a MySQL database within Azure that I’m hoping to connect through to the Prisma service. I have two issues at the moment.

  1. How can I tell Prisma to use my Azure DB instead of the Docker bundled mysql image?
  2. How do I take just the Prisma service and host it as an App Service in Azure?

I’ve had a look at the docs but couldn’t find anything specifically relating to my problems, the deployment guide for DigitalOcean (manual) seems to be the one most applicable to my situation but it doesn’t say anything about pointing to a different DB.

BONUS QUESTION: I was under the impression that running a database inside a container is a no no in production but this seems to be the default for Prisma, is there something I don’t understand about the way Prisma works that makes this okay?

Thanks :slight_smile:

EDIT: I have seen Advice on best practise? - Deploying graphql-yoga server w/ Prisma in production by @nilan which is helpful but I’m a little lost as a Docker newbie, I assume there’s some config I need to add to tell it where my database lives but I’m not sure where that goes.


#2

That’s not the default for Prisma, but for easier getting started, the local cluster comes with a mysql Docker image already, which is absolutely fine for development and even production, depending on your requirements.

You can do so using Docker/docker-compose. Here, under Cluster Deployment, you can find a couple of resources on that topic:

I don’t understand that question, can you elaborate?


#3

Hi Nilan thank you so much for your response! I’ve spent a lot of time learning how azure works and trying to figure out how prisma works so.

Ahh I see thank you for explaining, I’ve seen a lot of conflicting opinions on this, by ‘not the default for Prisma’ I assume that Prisma Cloud is actually running SQL servers rather than SQL containers?

Thank you I will take a look and report back my findings.

Sorry about this one, I think I’ve been trying to avoid learning how docker and azure works but now I understand that my question is a bit of a nonsense question. The question I now have instead of this (which actually makes sense) is how do I take the fargate template and convert it for azure so I can run my own cluster? I’ve made a start but I don’t feel as though I have a deep enough understanding. I’ve been looking at both this and this.


#4

You are connecting your own database to Prisma - so it is typically a database hosted in AWS, GCP, Azure, …


You could apply the Kubernetes tutorial to Azure, as it has Kubernetes support. Beyond that, it would be super interesting to hear more about whether or not Azure has a container abstraction similar to Fargate. I am not aware of any Prisma specific resources on that, but would love to help you moving in that direction :slight_smile:


#5

Ahh sorry I should’ve been clearer I was talking about the public cluster I have looked at creating a public cluster with Prisma Cloud but during development I’m fine with public.

Interesting, if I can figure out the Docker Compose stuff then perhaps this is a potential solution.

Azure has something called ‘Container Instances’ which can be compared to Fargate. I’ve also seen something called a ‘Container Service’ which looks like a good way to manage a Docker Swarm but I need to do more research into that one.

The part I’m struggling most with with my Azure Resource Manager template (CloudFormation equivalent) is making sure all the subnets and gateways are configured correctly as this is all very new to me, I’ve done the part for the Container Instance and it’s very similar to the Fargate template.