Configure Workers Service environments using wrangler?

I was excited about the new Services announcement, including service environments: https://blog.cloudflare.com/introducing-worker-services/

I wanted to try it out, so I created a blank new ts project with wrangler generate. Then following this doc, I tried to add a new environment in wrangler.toml like this:

name = "my-test-app-dev"
vars = { ENVIRONMENT = "dev" }
workers_dev = true

[env.production]
name = "my-test-app"
vars = { ENVIRONMENT = "production" }
route = "mydomain.com/*"
workers_dev = false

But when I deploy both of these, (wrangler publish and wrangler publish -e production), it doesn’t make one service with 2 environments, it creates 2 separate services each with one “production” environment.

How do I deploy to a non-production environment with wrangler, is that currently possible?

(Also, slightly related, I can’t delete services through the dashboard. The error is API Request Failed: DELETE /api/v4/accounts/<account_id>/workers/services/my-test-app (405). I assume this is just a bug?)

To benefit from this you will need a different npm package [email protected] instead of @cloudflare/wrangler
The devs found some issue, follow the bellow sites for more info.

NPM

GitHub

1 Like