From 2a3e9c84dfaad55882160ae24fa55e0dc909edd2 Mon Sep 17 00:00:00 2001 From: Bruno Germano Date: Wed, 9 Apr 2025 17:38:26 -0300 Subject: [PATCH] docs: adds documentation for deploying on Azion Adds a new documentation page detailing how to deploy Hono applications on the Azion Edge Platform. This guide covers setting up a new Hono project, running it locally, and deploying it using the Azion CLI. --- .vitepress/config.ts | 10 ++- docs/getting-started/azion.md | 135 ++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 docs/getting-started/azion.md diff --git a/.vitepress/config.ts b/.vitepress/config.ts index ec7d102d..3b410ca4 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -1,11 +1,11 @@ -import { defineConfig } from 'vitepress' +import { transformerTwoslash } from '@shikijs/vitepress-twoslash' +import { createFileSystemTypesCache } from '@shikijs/vitepress-twoslash/cache-fs' import type { DefaultTheme } from 'vitepress' +import { defineConfig } from 'vitepress' import { groupIconMdPlugin, groupIconVitePlugin, } from 'vitepress-plugin-group-icons' -import { transformerTwoslash } from '@shikijs/vitepress-twoslash' -import { createFileSystemTypesCache } from '@shikijs/vitepress-twoslash/cache-fs' const sidebars = (): DefaultTheme.SidebarItem[] => [ { @@ -65,6 +65,10 @@ const sidebars = (): DefaultTheme.SidebarItem[] => [ text: 'Ali Function Compute', link: '/docs/getting-started/ali-function-compute', }, + { + text: 'Azion', + link: '/docs/getting-started/azion', + }, { text: 'Service Worker', link: '/docs/getting-started/service-worker', diff --git a/docs/getting-started/azion.md b/docs/getting-started/azion.md new file mode 100644 index 00000000..b437e300 --- /dev/null +++ b/docs/getting-started/azion.md @@ -0,0 +1,135 @@ +# Azion Edge Functions + +[Azion Edge Functions](https://www.azion.com/en/products/edge-functions/) let you run code at the edge — closer to your users — for faster performance, lower latency, and enhanced scalability. Hono also runs smoothly on Azion’s Edge Platform. + +You can build your app locally and deploy it using [Azion CLI](https://www.azion.com/en/documentation/products/azion-cli/overview/), which provides simple commands to manage your edge applications. + +## 1. Setup + +Start a new Hono project using the **azion CLI** command. Select `Hono` preset when prompted. + +1. Initialize the project: + +```sh +azion init +``` + +2. Give your project a name, or press enter to accept the given suggestion: + +```sh +? Your application's name: (black-thor) +``` + +3. Choose the Hono preset: + +```sh +? Choose a preset: [Use arrows to move, type to filter] + Angular + Astro + Docusaurus + Eleventy + Emscripten + Gatsby + Hexo +> Hono + Hugo + Javascript + ... +``` + +4. Choose one of the available templates. + +5. With the template fetched and configured, you can choose to start a local development server. + +```sh +Do you want to start a local development server? (y/N) +``` + +Move into your project folder and install the dependencies: + +::: code-group + +```sh [npm] +cd [your-project-name] +npm i +``` + +```sh [yarn] +cd [your-project-name] +yarn +``` + +```sh [pnpm] +cd [your-project-name] +pnpm i +``` + +```sh [bun] +cd [your-project-name] +bun i +``` + +::: + +## 2. Hello World + +Edit `src/index.ts`: + +```ts +// src/index.ts +import { Hono } from 'hono' +const app = new Hono() + +app.get('/', (c) => c.text('Hello Azion!')) + +export default app +``` + +## 3. Run Locally + +Run the development server and open `http://localhost:3000` in your browser. + +::: code-group + +```sh [npm] +npm run dev +``` + +```sh [yarn] +yarn dev +``` + +```sh [pnpm] +pnpm dev +``` + +```sh [bun] +bun run dev +``` + +::: + +## 4. Deploy + +First, using the Azion CLI you will need to log in, if you haven’t done so already. This will authenticate your local environment with your Azion's account. + +```sh +azion login +``` + +Then, deploy your app with: + +```sh +azion deploy +``` + +Wait while the project is built and deployed to the Azion Edge Platform. + +> [!NOTE] +> Once the deployment is triggered, Azion will open the browser and take the user to a page on Azion Console where the deployment logs and process can be monitored. If it doesn’t open automatically, just click on the provided link. + +After the deployment is complete, you’ll receive a domain to access your Hono project on the Azion’s platform. + +Wait a few minutes so the propagation takes place, and then access your application using the provided domain, which should be similar to `https://xxxxxxx.map.azionedge.net`. + +If you don’t have an account yet, [sign up here](https://console.azion.com/signup/).