{"id":59025,"date":"2023-10-10T10:00:10","date_gmt":"2023-10-10T04:30:10","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=59025"},"modified":"2023-10-25T10:06:14","modified_gmt":"2023-10-25T04:36:14","slug":"how-to-setup-astro-cli-and-deploy-to-astro-windows","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-setup-astro-cli-and-deploy-to-astro-windows\/","title":{"rendered":"How to Setup Astro CLI and deploy to Astro (Windows)"},"content":{"rendered":"<h2><span style=\"font-weight: 400;\">Setup:<\/span><\/h2>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Download the optimal version of Astro for your Windows system from <\/span><a href=\"https:\/\/github.com\/astronomer\/astro-cli\/releases\"><span style=\"font-weight: 400;\">link<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Rename the downloaded file to \u201castro.exe\u201d and save it.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Add the file path to environment variables.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">To check if Astro has been configured correctly, run \u201c<\/span><b>astro<\/b><span style=\"font-weight: 400;\">\u201d command<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">On cmd. After the successful configuration of Astro CLI, you should get a response like the one below:<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-59002\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/1-4.png\" alt=\"\" width=\"1920\" height=\"912\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/1-4.png 1920w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/1-4-300x143.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/1-4-1024x486.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/1-4-768x365.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/1-4-1536x730.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/1-4-624x296.png 624w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<h2><span style=\"font-weight: 400;\">How to make your first airflow DAG:<\/span><\/h2>\n<ol>\n<li><span style=\"font-weight: 400;\">Make a project directory for e.g. \u201c<\/span><b>test\u201d<\/b><span style=\"font-weight: 400;\"> and run \u201c<\/span><b>astro dev init<\/b><span style=\"font-weight: 400;\">\u201d <\/span><span style=\"font-weight: 400;\">. What this command will do is it will initialize an Astro project in the local directory with all necessary airflow files and folders that are required to run airflow.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Open the project directory \u201c<\/span><b>test<\/b><span style=\"font-weight: 400;\">\u201d <\/span><b>\u00a0<\/b><span style=\"font-weight: 400;\">in any IDE.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">In \u201c<\/span><b>test<\/b><span style=\"font-weight: 400;\">\u201d go to \u201c<\/span><b>dags<\/b><span style=\"font-weight: 400;\">\u201d\u00a0 and create a Python script of airflow dag \u201ctest_dag.py\u201d in my case.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Below is an example:<\/span><\/li>\n<\/ol>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-59003\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/2-2.png\" alt=\"\" width=\"1080\" height=\"746\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/2-2.png 1080w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/2-2-300x207.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/2-2-1024x707.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/2-2-768x530.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/2-2-624x431.png 624w\" sizes=\"(max-width: 1080px) 100vw, 1080px\" \/><\/p>\n<h2><span style=\"font-weight: 400;\">Deploy DAGs on Astro:<\/span><\/h2>\n<ol>\n<li><span style=\"font-weight: 400;\">Assuming we have access to an Astro account, we will run \u201c<strong>Astro login<\/strong>\u201d command in CLI and then enter.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">A pop-up window will appear in the default browser to ask for a login to Astro account.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Login using your preferred way and allow access.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Below are the screen grab of the process.<\/span>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-59024\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/3-1.png\" alt=\"\" width=\"679\" height=\"427\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/3-1.png 679w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/3-1-300x189.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/3-1-624x392.png 624w\" sizes=\"(max-width: 679px) 100vw, 679px\" \/><\/li>\n<li><span style=\"font-weight: 400;\">After successful login, we can create an Astro workspace using<br \/>\n<\/span>\u201c<strong>astro workspace create &#8211;name &#8220;name of workspace&#8221; &#8211;enforce-ci-cd ON<\/strong>\u201d.<br \/>\nIn our case, we are sticking with the \u201cdata engineer\u201d workspace.<\/li>\n<li><span style=\"font-weight: 400;\">To switch to a preferred workspace, use \u201c<strong>astro workspace switch<\/strong>\u201d and select the number.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Post that, use Astro UI to create the deployment. See below\n<p><\/span><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-59004 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/4-1-1024x273.png\" alt=\"\" width=\"625\" height=\"167\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/4-1-1024x273.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/4-1-300x80.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/4-1-768x205.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/4-1-1536x410.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/4-1-624x166.png 624w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/4-1.png 1920w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/li>\n<li><span style=\"font-weight: 400;\">Now use \u201c<strong>Astro deploy<\/strong>\u201d command to check for errors and send out all of your dags to Astro.\n<p><\/span><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-59005\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/5-1.png\" alt=\"\" width=\"1111\" height=\"470\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/5-1.png 1111w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/5-1-300x127.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/5-1-1024x433.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/5-1-768x325.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/5-1-624x264.png 624w\" sizes=\"(max-width: 1111px) 100vw, 1111px\" \/><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-59006\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/6-1.png\" alt=\"\" width=\"1187\" height=\"482\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/6-1.png 1187w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/6-1-300x122.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/6-1-1024x416.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/6-1-768x312.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/6-1-624x253.png 624w\" sizes=\"(max-width: 1187px) 100vw, 1187px\" \/><\/li>\n<li><span style=\"font-weight: 400;\">After successful deployment, we can see all of our dags in \u201c<strong>dags<\/strong>\u201c section of Astro UI.\n<p><\/span><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-59007\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/7-1.png\" alt=\"\" width=\"1895\" height=\"930\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/7-1.png 1895w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/7-1-300x147.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/7-1-1024x503.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/7-1-768x377.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/7-1-1536x754.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/7-1-624x306.png 624w\" sizes=\"(max-width: 1895px) 100vw, 1895px\" \/><\/li>\n<li><span style=\"font-weight: 400;\">Now, we can trigger them manually or schedule them to perform our tasks.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Adding below screen grabs of the output of our dag.\n<p><\/span><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-59008\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/8-1.png\" alt=\"\" width=\"1920\" height=\"930\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/10\/8-1.png 1920w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/8-1-300x145.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/8-1-1024x496.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/8-1-768x372.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/8-1-1536x744.png 1536w, \/blog\/wp-ttn-blog\/uploads\/2023\/10\/8-1-624x302.png 624w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><\/li>\n<\/ol>\n<h2><span style=\"font-weight: 400;\">For local testing and development:<\/span><\/h2>\n<ol>\n<li><span style=\"font-weight: 400;\">To test a dag in the local environment before deploying it to Astro, we can use \u201c<\/span><b>astro dev start<\/b><span style=\"font-weight: 400;\">\u201d. But to run airflow on the local machine, we will have to set up docker refer to this <\/span><a href=\"https:\/\/docs.astronomer.io\/astro\/cli\/install-cli\"><span style=\"font-weight: 400;\">link<\/span><\/a><span style=\"font-weight: 400;\"> for further process.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Now go to \u201c<strong>localhost:8080\u201d<\/strong> and use credentials username=admin,password=admin to login.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Now, you can try all of your dag for further debugging and optimization before deploying it to Astro.<\/span><\/li>\n<\/ol>\n<h2>References:<\/h2>\n<ol>\n<li>https:\/\/docs.astronomer.io\/<\/li>\n<li>https:\/\/academy.astronomer.io\/your-onboarding-journey<\/li>\n<\/ol>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>Setup: Download the optimal version of Astro for your Windows system from link. Rename the downloaded file to \u201castro.exe\u201d and save it. Add the file path to environment variables. To check if Astro has been configured correctly, run \u201castro\u201d command On cmd. After the successful configuration of Astro CLI, you should get a response like [&hellip;]<\/p>\n","protected":false},"author":1664,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":509},"categories":[1395,4831,1994],"tags":[5499,5497,5498],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/59025"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1664"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=59025"}],"version-history":[{"count":2,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/59025\/revisions"}],"predecessor-version":[{"id":59269,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/59025\/revisions\/59269"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=59025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=59025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=59025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}