{"id":58,"date":"2025-01-01T08:48:32","date_gmt":"2025-01-01T03:18:32","guid":{"rendered":"https:\/\/manjunathpr.com\/?p=58"},"modified":"2025-01-01T08:48:32","modified_gmt":"2025-01-01T03:18:32","slug":"how-to-deploy-hasura-on-aca-via-azure-cli","status":"publish","type":"post","link":"https:\/\/manjunathpr.com\/index.php\/2025\/01\/01\/how-to-deploy-hasura-on-aca-via-azure-cli\/","title":{"rendered":"How to &#8211; Deploy Hasura on ACA via Azure CLI"},"content":{"rendered":"\n<p>Hasura, a powerful GraphQL engine, offers documentation on deploying it using <a href=\"https:\/\/hasura.io\/docs\/2.0\/deployment\/deployment-guides\/azure-container-instances-postgres\/\" data-type=\"link\" data-id=\"https:\/\/hasura.io\/docs\/2.0\/deployment\/deployment-guides\/azure-container-instances-postgres\/\">Azure Container Instances (ACI)<\/a>, a service that allows you to run containerized applications in the cloud without managing the underlying infrastructure. However, I encountered several challenges during the process, which highlighted the limitations of the existing approach and underscored the need for a more user-friendly and scalable solution. Below are the pain points with the approach<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>The existing documentation requires significant trial and error to execute successfully. <\/li>\n\n\n\n<li>The provided ARM templates are riddled with issues, making the one-click deployment process unusable.<\/li>\n\n\n\n<li>ACI does not automatically adjust its resources based on demand. To scale up, you have to delete the container and redeploy, which can be inconvenient.<\/li>\n<\/ol>\n\n\n\n<p>To overcome these issues, I found that Azure Container Apps (ACA) offers a better alternative. ACA provides the necessary flexibility while removing the need to deal with complex configurations, such as those in Azure Kubernetes Service (AKS). Here&#8217;s a step-by-step guide to deploying Hasura on ACA.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>? <strong>Prerequisites<\/strong><\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>Azure CLI<\/strong>: Install <a href=\"https:\/\/learn.microsoft.com\/en-us\/cli\/azure\/install-azure-cli-windows?tabs=azure-cli\">Azure CLI<\/a> on your machine and log in using an account with sufficient access to create resources.<strong>OR<\/strong><\/li>\n\n\n\n<li><strong>Azure Portal<\/strong>: Log in to <a href=\"https:\/\/portal.azure.com\">portal.azure.com<\/a> and run the Bash shell directly in the portal for a faster and easier setup.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>? <strong>Deployment Steps<\/strong><\/p>\n\n\n\n<p>\u2699\ufe0f <strong>Step 1: Register the Resource Provider<\/strong><\/p>\n\n\n\n<p>To use Azure Container Apps, you need to first register the <code>Microsoft.ContainerService<\/code> resource provider.<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Navigate to <strong>Subscriptions<\/strong>.<\/li>\n\n\n\n<li>Select your subscription.<\/li>\n\n\n\n<li>Go to <strong>Resource Providers<\/strong>.<\/li>\n\n\n\n<li>Search for <code>Microsoft.ContainerService<\/code> and click <strong>Register<\/strong>.<br><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"550\" src=\"https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/2025-01-01_08-13-1024x550.png\" alt=\"\" class=\"wp-image-65\" srcset=\"https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/2025-01-01_08-13-1024x550.png 1024w, https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/2025-01-01_08-13-300x161.png 300w, https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/2025-01-01_08-13-768x413.png 768w, https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/2025-01-01_08-13.png 1323w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>? <strong>Step 2: Create a Resource Group<\/strong><\/p>\n\n\n\n<p>Run the following command to create a resource group:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>az group create --name &lt;YOUR_RG_NAME&gt; --location southeastasia<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>? <strong>Step 3: Create an Azure PostgreSQL Flexible Server<\/strong><\/p>\n\n\n\n<p>Hasura requires a database to store its configuration. Create a PostgreSQL Flexible Server using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>az postgres flexible-server create --resource-group &lt;YOUR_RG_NAME> \\\n   --name \"&lt;YOUR_POSTGRES_DB_SERVER_NAME>\" \\\n   --location southeastasia \\\n   --admin-user &lt;YOUR_POSTGRES_DB_ADMIN_USERNAME> \\\n   --admin-password \"&lt;YOUR_POSTGRES_DB_ADMIN_PWD>\" \\\n   --sku-name standard_b1ms \\\n   --tier Burstable \\\n   --version 16 \\\n   --database-name &lt;YOUR_POSTGRES_DB_NAME><\/code><\/pre>\n\n\n\n<p>Enable the database to be accessible by Azure services: This step ensures that Hasura can communicate with the database for storing and retrieving its configuration and operational data.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>az postgres flexible-server firewall-rule create \\\n   --resource-group &lt;YOUR_RG_NAME&gt; \\\n   --name &lt;YOUR_POSTGRES_DB_SERVER_NAME&gt; \\\n   --rule-name allowazureservices \\\n   --start-ip-address 0.0.0.0 \\\n   --end-ip-address 0.0.0.0<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>? <strong>Step 4: Configure PostgreSQL Server Parameters<\/strong><\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Navigate to your PostgreSQL server in the Azure Portal.<\/li>\n\n\n\n<li>Go to <strong>Server Parameters<\/strong>.<\/li>\n\n\n\n<li>Search for <strong>Extensions<\/strong>.<\/li>\n\n\n\n<li>Under the <code>azure.extensions<\/code> parameter, set the value to <code>PGCRYPTO<\/code>.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"975\" height=\"743\" src=\"https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/2025-01-01_08-15.png\" alt=\"\" class=\"wp-image-66\" srcset=\"https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/2025-01-01_08-15.png 975w, https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/2025-01-01_08-15-300x229.png 300w, https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/2025-01-01_08-15-768x585.png 768w\" sizes=\"(max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>? <strong>Step 5: Create the Container App Environment<\/strong><\/p>\n\n\n\n<p>Create an environment for your container apps:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>az containerapp env create \\\n  --name &lt;YOUR_ACA_ENV_NAME&gt; \\\n  --resource-group &lt;YOUR_RG_NAME&gt; \\\n  --location southeastasia<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>? <strong>Step 6: Deploy Hasura on ACA<\/strong><\/p>\n\n\n\n<p>Finally, create a container app and deploy Hasura. Use the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>az containerapp create \\\n  --name &lt;YOUR_ACA_APP_NAME&gt; \\\n  --resource-group &lt;YOUR_RG_NAME&gt; \\\n  --environment &lt;YOUR_ACA_ENV_NAME&gt; \\\n  --image hasura\/graphql-engine \\\n  --ingress external \\\n  --target-port 80 \\\n  --env-vars HASURA_GRAPHQL_SERVER_PORT=80 \\\n             HASURA_GRAPHQL_ENABLE_CONSOLE=true \\\n             HASURA_GRAPHQL_ADMIN_SECRET=\"&lt;ADMIN_PASSWORD_THAT_YOU_CAN_REMEMBER&gt;\" \\\n             HASURA_GRAPHQL_METADATA_DATABASE_URL=\"postgres:\/\/&lt;YOUR_POSTGRES_DB_ADMIN_USERNAME&gt;:&lt;YOUR_POSTGRES_DB_ADMIN_PWD&gt;@&lt;YOUR_POSTGRES_DB_SERVER_NAME&gt;.postgres.database.azure.com:5432\/&lt;YOUR_POSTGRES_DB_NAME&gt;?sslmode=require\" \\\n  --min-replicas 1 \\\n  --max-replicas 3<\/code><\/pre>\n\n\n\n<p>? <strong>Note<\/strong>: Do not configure the actual DB which Hasura has to run on. This can be done once you deploy Hasura and configure the DB within it.<\/p>\n\n\n\n<p>? <strong>Step 7: Verify Deployment<\/strong><\/p>\n\n\n\n<p>And that&#8217;s it! Hasura will be up and running. To get the URL, run the command below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>az containerapp show \\\n  --name &lt;YOUR_ACA_APP_NAME&gt; \\\n  --resource-group &lt;YOUR_RG_NAME&gt; \\\n  --output table<\/code><\/pre>\n\n\n\n<p>This will provide you with a table that includes a column called <code>Fqdn<\/code>. That would be the URL for your app\u2014just append <code>\/console<\/code> to access the Hasura Console.<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"414\" src=\"https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/image-1024x414.png\" alt=\"\" class=\"wp-image-67\" srcset=\"https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/image-1024x414.png 1024w, https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/image-300x121.png 300w, https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/image-768x310.png 768w, https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/image-1536x621.png 1536w, https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/image.png 2006w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hasura, a powerful GraphQL engine, offers documentation on deploying it using Azure Container Instances (ACI), a service that allows you to run containerized applications in the cloud without managing the underlying infrastructure. However, I encountered several challenges during the process, which highlighted the limitations of the existing approach and underscored the need for a more [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":68,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,2,22,5,4,23,21,6],"tags":[8,9,19,10,11,20,18,13],"class_list":["post-58","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-cloud-computing","category-container-apps","category-containers","category-devops","category-hasura","category-how-to","category-kubernetes","tag-azure","tag-cloudcomputing","tag-containerapps","tag-containers","tag-devops","tag-graphql","tag-hasura","tag-kubernetes"],"jetpack_featured_media_url":"https:\/\/manjunathpr.com\/wp-content\/uploads\/2025\/01\/aminutetolearn.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/manjunathpr.com\/index.php\/wp-json\/wp\/v2\/posts\/58","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/manjunathpr.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/manjunathpr.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/manjunathpr.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/manjunathpr.com\/index.php\/wp-json\/wp\/v2\/comments?post=58"}],"version-history":[{"count":5,"href":"https:\/\/manjunathpr.com\/index.php\/wp-json\/wp\/v2\/posts\/58\/revisions"}],"predecessor-version":[{"id":70,"href":"https:\/\/manjunathpr.com\/index.php\/wp-json\/wp\/v2\/posts\/58\/revisions\/70"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/manjunathpr.com\/index.php\/wp-json\/wp\/v2\/media\/68"}],"wp:attachment":[{"href":"https:\/\/manjunathpr.com\/index.php\/wp-json\/wp\/v2\/media?parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/manjunathpr.com\/index.php\/wp-json\/wp\/v2\/categories?post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/manjunathpr.com\/index.php\/wp-json\/wp\/v2\/tags?post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}