From 09d7d631bd25edfb48d682995977a3664a67a816 Mon Sep 17 00:00:00 2001 From: Andrew Steurer Date: Fri, 12 Jul 2024 15:27:19 -0600 Subject: [PATCH] updating README and refactoring spin.toml Signed-off-by: Andrew Steurer --- README.md | 25 +++++++++++++++++++------ spin.toml | 18 ++++++------------ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index a345be5..cfcca7e 100644 --- a/README.md +++ b/README.md @@ -30,16 +30,29 @@ Although Spin offers some amazing features, there are some situations for which In the `spin.toml` file of the Spin application to which you want to add the Azure component, you'll need to tell Spin that you want the component to be part of your app, and you'll need to give your application permission to make HTTP calls to the Azure component: ```toml +# Don't forget that the main application needs to have permission to access the Azure client component, so don't forget to add either 'http://localhost:3000' or 'http://name-of-azure-component.spin.internal' as an allowed outbound host (see https://developer.fermyon.com/spin/v2/http-outbound#local-service-chaining for more details) + +[variables] +az_account_name = { required = true, secret = true } +az_shared_key = { required = true, secret = true } + [[trigger.http]] -# See article on structuring Spin applications: https://developer.fermyon.com/spin/v2/spin-application-structure -route = "/desired/route/for/azure/component/..." +# For defining a custom route, see article on structuring Spin applications: https://developer.fermyon.com/spin/v2/spin-application-structure +route = "/..." component = "name-of-azure-component" -[[component.name-of-azure-component]] +[component.name-of-azure-component] # Be sure to use the current version of the package. -source = { registry = "fermyon.com", package = "fermyon-experimental:azure-client", version = "1.0.0" } -# See article on local service chaining: https://developer.fermyon.com/spin/v2/http-outbound#local-service-chaining -allowed_outbound_hosts = ["http://name-of-azure-component.spin.internal"] +source = { registry = "fermyon.com", package = "fermyon-experimental:azure-client", version = " 0.1.0" } +# If the app needs to access multiple storage accounts, use "https://*.{{blob|queue}}.core.windows.net" +allowed_outbound_hosts = [ + "https://{{ az_account_name }}.blob.core.windows.net", + "https://{{ az_account_name }}.queue.core.windows.net", +] + +[component.name-of-azure-component.variables] +az_account_name = "{{ az_account_name }}" +az_shared_key = "{{ az_shared_key }}" ``` Once these entries have been added to the `spin.toml` file, you can run `spin build`. diff --git a/spin.toml b/spin.toml index 60031f8..1254b48 100644 --- a/spin.toml +++ b/spin.toml @@ -6,10 +6,9 @@ name = "Go Azure" version = "0.1.0" authors = ["Andrew Steurer "] -[variables] -az_account_name = { required = true, secret = true } -az_shared_key = { required = true, secret = true } - +# [variables] +# az_account_name = { required = true } +# az_shared_key = { required = true } [[trigger.http]] route = "/..." @@ -17,16 +16,11 @@ component = "go-azure" [component.go-azure] source = "main.wasm" -# If the app needs to access multiple storage accounts, use "https://*.{{blob|queue}}.core.windows.net" -allowed_outbound_hosts = [ - "https://{{ az_account_name }}.blob.core.windows.net", - "https://{{ az_account_name }}.queue.core.windows.net", -] [component.go-azure.build] command = "tinygo build -target=wasi -gc=leaking -no-debug -o main.wasm main.go" watch = ["**/*.go", "go.mod"] -[component.go-azure.variables] -az_account_name = "{{ az_account_name }}" -az_shared_key = "{{ az_shared_key }}" \ No newline at end of file +# [component.go-azure.variables] +# az_account_name = "{{ az_account_name }}" +# az_shared_key = "{{ az_shared_key }}" \ No newline at end of file