Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Last active June 17, 2020 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinyoo/fcba3e387d240a057e76a28f233fec82 to your computer and use it in GitHub Desktop.
Save justinyoo/fcba3e387d240a057e76a28f233fec82 to your computer and use it in GitHub Desktop.
Hosting Blazor Web Assembly App on Azure Static Web App
dotnet run -p BlazorNpmSample
- name: Setup .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.300'
- name: Publish Blazor WASM app
shell: bash
run: |
dotnet publish BlazorNpmSample -c Release -o published
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v0.0.1-preview
with:
...
app_location: "published/wwwroot"
api_location: ""
app_artifact_location: "published/wwwroot"
func start --script-root BlazorApiSample
http://localhost:7071/api/hello?count=1
const axios = require('axios');
module.exports = async function (context, req) {
let baseUri = process.env.API__BASE_URI;
let endpoint = process.env.API__ENDPOINT
let authKey = process.env.API__AUTH_KEY === undefined ? '' : process.env.API__AUTH_KEY;
let count = req.query.count === undefined ? 0 : req.query.count;
let requestUri = baseUri + endpoint + '?count=' + count + '&code=' + authKey;
let response = await axios.get(requestUri);
let result = { "text": response.data.message };
context.res = {
// status: 200, /* Defaults to 200 */
body: result
};
}
{
...
"Values": {
...
"API__BASE_URI": "http://localhost:7071/api/",
"API__ENDPOINT": "hello",
"API__AUTH_KEY": ""
}
}
func start --port 7072 --script-root BlazorProxySample
{
...
"Values": {
...
},
"Host": {
"CORS": "*"
}
}
- name: Update appsettings.json
shell: bash
run: |
echo '{ "PROXY_BASE_URI": "/api/", "PROXY_ENDPOINT": "hello " }' > BlazorNpmSample/wwwroot/appsettings.json
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v0.0.1-preview
with:
app_location: "published/wwwroot"
api_location: "BlazorProxySample"
app_artifact_location: "published/wwwroot"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment