Last active
June 17, 2020 08:05
-
-
Save justinyoo/fcba3e387d240a057e76a28f233fec82 to your computer and use it in GitHub Desktop.
Hosting Blazor Web Assembly App on Azure Static Web App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dotnet run -p BlazorNpmSample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: '3.1.300' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Publish Blazor WASM app | |
shell: bash | |
run: | | |
dotnet publish BlazorNpmSample -c Release -o published |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func start --script-root BlazorApiSample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://localhost:7071/api/hello?count=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
... | |
"Values": { | |
... | |
"API__BASE_URI": "http://localhost:7071/api/", | |
"API__ENDPOINT": "hello", | |
"API__AUTH_KEY": "" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func start --port 7072 --script-root BlazorProxySample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
... | |
"Values": { | |
... | |
}, | |
"Host": { | |
"CORS": "*" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Update appsettings.json | |
shell: bash | |
run: | | |
echo '{ "PROXY_BASE_URI": "/api/", "PROXY_ENDPOINT": "hello " }' > BlazorNpmSample/wwwroot/appsettings.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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