Skip to content

Commit 67475ba

Browse files
committed
docs: update Cloudflare to Azion migration guide with revised installation commands and function signature details
1 parent 059f363 commit 67475ba

1 file changed

Lines changed: 25 additions & 10 deletions

File tree

src/content/docs/en/pages/guides/cloudflare-to-azion/cf-to-azion-comprehensive-guide.mdx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ A migration can appear successful when the build passes but fail later when runt
167167

168168
| Task | Cloudflare | Azion |
169169
| :--- | :--------- | :---- |
170-
| **Install** | `npm install -g wrangler` | `curl -fsSL https://cli.azion.app/install.sh \| bash` |
171-
| **Login** | `wrangler login` | `azion login` |
172-
| **Local dev** | `wrangler pages dev ./dist` | `azion dev` |
173-
| **Deploy** | `wrangler pages deploy ./dist` | `azion deploy` |
170+
| **Install** | `npm i -D wrangler@latest` | `curl -fsSL https://cli.azion.app/install.sh \| bash` |
171+
| **Login** | `npx wrangler login` | `azion login` |
172+
| **Local dev** | `npx wrangler pages dev ./dist` | `azion dev` |
173+
| **Deploy** | `npx wrangler pages deploy ./dist` | `azion deploy` |
174174

175175
#### Review Questions
176176

@@ -365,10 +365,10 @@ Functions are the computational engine of modern distributed applications. They
365365

366366
| Aspect | Cloudflare Workers | Azion Functions |
367367
| :----- | :----------------- | :-------------- |
368-
| **Function signature** | `fetch(request, env, ctx)` | `fetch(request)` |
368+
| **Function signature** | `fetch(request, env, ctx)` | `fetch(request, env, ctx)` |
369369
| **Environment access** | `env.VARIABLE` | `Azion.env.get('VARIABLE')` |
370-
| **Memory** | 128 MB free, 2 GB paid | 512 MB all plans |
371-
| **Cold starts** | Possible | Eliminated |
370+
| **Memory** | 128 MB (all plans) | Check documentation for current limits |
371+
| **Cold starts** | Possible | Possible (minimized with edge distribution) |
372372

373373
#### Update Function Signature
374374

@@ -383,7 +383,7 @@ export default {
383383
384384
// After: Azion
385385
export default {
386-
async fetch(request) {
386+
async fetch(request, env, ctx) {
387387
const apiKey = Azion.env.get('API_KEY');
388388
return fetch(apiUrl, { headers: { 'Authorization': \`Bearer \${apiKey}\` }});
389389
}
@@ -402,11 +402,24 @@ const country = request.metadata['geoip_country_code'];
402402

403403
#### Update Service Imports
404404

405+
Azion provides two SQL interfaces:
406+
- **Runtime API** (`azion:sql`) — for querying databases from Edge Functions
407+
- **Azion Lib SDK** (`azion/sql`) — for managing databases via API (build tools, scripts)
408+
405409
<Code lang="javascript" code={`
406410
import { Database } from 'azion:sql';
407411
408-
const db = new Database('my-database');
409-
const result = await db.prepare('SELECT * FROM users').all();
412+
// Open connection (async)
413+
const db = await Database.open('my-database');
414+
415+
// Query and iterate results
416+
const rows = await db.query('SELECT * FROM users');
417+
let row = await rows.next();
418+
while (row) {
419+
const name = row.getString(0); // access column by index
420+
console.log(name);
421+
row = await rows.next();
422+
}
410423
`} />
411424

412425
#### Reference documentation
@@ -415,6 +428,8 @@ const result = await db.prepare('SELECT * FROM users').all();
415428
* [Functions Instances](https://www.azion.com/en/documentation/products/build/applications/functions-instances/)
416429
* [Runtime APIs](https://www.azion.com/en/documentation/products/build/develop-with-azion/runtime-apis/)
417430
* [JavaScript Runtime APIs reference](https://www.azion.com/en/documentation/runtime-apis/javascript/)
431+
* [SQL Database API (Runtime)](https://www.azion.com/en/documentation/runtime/api-reference/sql-database.md)
432+
* [Azion Lib SQL (SDK)](https://www.azion.com/en/documentation/products/azion-lib/sql.md)
418433

419434
### 7. Migrating Load Balancing
420435

0 commit comments

Comments
 (0)