From 625af76a0003ba96b2671afa24e812b66878ff22 Mon Sep 17 00:00:00 2001 From: Charles Lee Date: Wed, 19 Jan 2022 11:13:25 +1100 Subject: [PATCH 1/3] ci: add Azure Static Web Apps workflow file on-behalf-of: @Azure opensource@microsoft.com --- ...re-static-web-apps-happy-sky-0472ab90f.yml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/azure-static-web-apps-happy-sky-0472ab90f.yml diff --git a/.github/workflows/azure-static-web-apps-happy-sky-0472ab90f.yml b/.github/workflows/azure-static-web-apps-happy-sky-0472ab90f.yml new file mode 100644 index 0000000..af2fdb6 --- /dev/null +++ b/.github/workflows/azure-static-web-apps-happy-sky-0472ab90f.yml @@ -0,0 +1,45 @@ +name: Azure Static Web Apps CI/CD + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened, closed] + branches: + - main + +jobs: + build_and_deploy_job: + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') + runs-on: ubuntu-latest + name: Build and Deploy Job + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_HAPPY_SKY_0472AB90F }} + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: "/" # App source code path + api_location: "api" # Api source code path - optional + output_location: "dist/angular-basic" # Built app content directory - optional + ###### End of Repository/Build Configurations ###### + + close_pull_request_job: + if: github.event_name == 'pull_request' && github.event.action == 'closed' + runs-on: ubuntu-latest + name: Close Pull Request Job + steps: + - name: Close Pull Request + id: closepullrequest + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_HAPPY_SKY_0472AB90F }} + action: "close" From 8bcf4ad5758b88d1c741e5856cc9c7c0fa7d3c81 Mon Sep 17 00:00:00 2001 From: Charles Lee Date: Wed, 19 Jan 2022 11:58:08 +1100 Subject: [PATCH 2/3] ci: add Azure Static Web Apps workflow file on-behalf-of: @Azure opensource@microsoft.com --- ...atic-web-apps-thankful-water-0e251610f.yml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/azure-static-web-apps-thankful-water-0e251610f.yml diff --git a/.github/workflows/azure-static-web-apps-thankful-water-0e251610f.yml b/.github/workflows/azure-static-web-apps-thankful-water-0e251610f.yml new file mode 100644 index 0000000..df14bcd --- /dev/null +++ b/.github/workflows/azure-static-web-apps-thankful-water-0e251610f.yml @@ -0,0 +1,45 @@ +name: Azure Static Web Apps CI/CD + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened, closed] + branches: + - main + +jobs: + build_and_deploy_job: + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') + runs-on: ubuntu-latest + name: Build and Deploy Job + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_THANKFUL_WATER_0E251610F }} + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: "/" # App source code path + api_location: "api" # Api source code path - optional + output_location: "dist/angular-basic" # Built app content directory - optional + ###### End of Repository/Build Configurations ###### + + close_pull_request_job: + if: github.event_name == 'pull_request' && github.event.action == 'closed' + runs-on: ubuntu-latest + name: Close Pull Request Job + steps: + - name: Close Pull Request + id: closepullrequest + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_THANKFUL_WATER_0E251610F }} + action: "close" From 9fe2a8a918ecbce79ab8567446078a8e82c80cd4 Mon Sep 17 00:00:00 2001 From: Charles Lee Date: Wed, 19 Jan 2022 16:54:58 +1100 Subject: [PATCH 3/3] changes from tutorial --- api/.funcignore | 7 +++ api/.gitignore | 94 +++++++++++++++++++++++++++++++++++++ api/.vscode/extensions.json | 5 ++ api/.vscode/launch.json | 12 +++++ api/.vscode/settings.json | 8 ++++ api/.vscode/tasks.json | 23 +++++++++ api/host.json | 15 ++++++ api/message/function.json | 19 ++++++++ api/message/index.js | 5 ++ api/message/sample.dat | 3 ++ api/package.json | 11 +++++ api/proxies.json | 4 ++ src/app/app.component.ts | 12 +++-- src/app/app.module.ts | 5 +- 14 files changed, 218 insertions(+), 5 deletions(-) create mode 100644 api/.funcignore create mode 100644 api/.gitignore create mode 100644 api/.vscode/extensions.json create mode 100644 api/.vscode/launch.json create mode 100644 api/.vscode/settings.json create mode 100644 api/.vscode/tasks.json create mode 100644 api/host.json create mode 100644 api/message/function.json create mode 100644 api/message/index.js create mode 100644 api/message/sample.dat create mode 100644 api/package.json create mode 100644 api/proxies.json diff --git a/api/.funcignore b/api/.funcignore new file mode 100644 index 0000000..5179222 --- /dev/null +++ b/api/.funcignore @@ -0,0 +1,7 @@ +*.js.map +*.ts +.git* +.vscode +local.settings.json +test +tsconfig.json \ No newline at end of file diff --git a/api/.gitignore b/api/.gitignore new file mode 100644 index 0000000..772851c --- /dev/null +++ b/api/.gitignore @@ -0,0 +1,94 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TypeScript output +dist +out + +# Azure Functions artifacts +bin +obj +appsettings.json +local.settings.json \ No newline at end of file diff --git a/api/.vscode/extensions.json b/api/.vscode/extensions.json new file mode 100644 index 0000000..26786f9 --- /dev/null +++ b/api/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "ms-azuretools.vscode-azurefunctions" + ] +} diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json new file mode 100644 index 0000000..e7be044 --- /dev/null +++ b/api/.vscode/launch.json @@ -0,0 +1,12 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to Node Functions", + "type": "node", + "request": "attach", + "port": 9229, + "preLaunchTask": "func: host start" + } + ] +} \ No newline at end of file diff --git a/api/.vscode/settings.json b/api/.vscode/settings.json new file mode 100644 index 0000000..3f445e7 --- /dev/null +++ b/api/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "azureFunctions.deploySubpath": ".", + "azureFunctions.postDeployTask": "npm install (functions)", + "azureFunctions.projectLanguage": "JavaScript", + "azureFunctions.projectRuntime": "~3", + "debug.internalConsoleOptions": "neverOpen", + "azureFunctions.preDeployTask": "npm prune (functions)" +} \ No newline at end of file diff --git a/api/.vscode/tasks.json b/api/.vscode/tasks.json new file mode 100644 index 0000000..3471eb6 --- /dev/null +++ b/api/.vscode/tasks.json @@ -0,0 +1,23 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "func", + "command": "host start", + "problemMatcher": "$func-node-watch", + "isBackground": true, + "dependsOn": "npm install (functions)" + }, + { + "type": "shell", + "label": "npm install (functions)", + "command": "npm install" + }, + { + "type": "shell", + "label": "npm prune (functions)", + "command": "npm prune --production", + "problemMatcher": [] + } + ] +} \ No newline at end of file diff --git a/api/host.json b/api/host.json new file mode 100644 index 0000000..3f33af1 --- /dev/null +++ b/api/host.json @@ -0,0 +1,15 @@ +{ + "version": "2.0", + "logging": { + "applicationInsights": { + "samplingSettings": { + "isEnabled": true, + "excludedTypes": "Request" + } + } + }, + "extensionBundle": { + "id": "Microsoft.Azure.Functions.ExtensionBundle", + "version": "[2.*, 3.0.0)" + } +} diff --git a/api/message/function.json b/api/message/function.json new file mode 100644 index 0000000..7eb1f8f --- /dev/null +++ b/api/message/function.json @@ -0,0 +1,19 @@ +{ + "bindings": [ + { + "authLevel": "anonymous", + "type": "httpTrigger", + "direction": "in", + "name": "req", + "methods": [ + "get", + "post" + ] + }, + { + "type": "http", + "direction": "out", + "name": "res" + } + ] +} diff --git a/api/message/index.js b/api/message/index.js new file mode 100644 index 0000000..cbbabf8 --- /dev/null +++ b/api/message/index.js @@ -0,0 +1,5 @@ +module.exports = async function (context, req) { + context.res.json({ + text: "Hello from the API" + }); +}; \ No newline at end of file diff --git a/api/message/sample.dat b/api/message/sample.dat new file mode 100644 index 0000000..26aac46 --- /dev/null +++ b/api/message/sample.dat @@ -0,0 +1,3 @@ +{ + "name": "Azure" +} \ No newline at end of file diff --git a/api/package.json b/api/package.json new file mode 100644 index 0000000..10f08ee --- /dev/null +++ b/api/package.json @@ -0,0 +1,11 @@ +{ + "name": "api", + "version": "1.0.0", + "description": "", + "scripts": { + "start": "func start", + "test": "echo \"No tests yet...\"" + }, + "dependencies": {}, + "devDependencies": {} +} diff --git a/api/proxies.json b/api/proxies.json new file mode 100644 index 0000000..b385252 --- /dev/null +++ b/api/proxies.json @@ -0,0 +1,4 @@ +{ + "$schema": "http://json.schemastore.org/proxies", + "proxies": {} +} diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 5e2ec6a..2c1d754 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,9 +1,15 @@ +import { HttpClient } from '@angular/common/http'; import { Component } from '@angular/core'; @Component({ selector: 'app-root', - template: `
Hello {{value}}
`, + template: `
{{message}} !!
`, }) export class AppComponent { - value = 'World'; -} + message = ''; + + constructor(private http: HttpClient) { + this.http.get('/api/message') + .subscribe((resp: any) => this.message = resp.text); + } +} \ No newline at end of file diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 712f530..bb46e7d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,11 +1,12 @@ import { BrowserModule } from "@angular/platform-browser"; import { NgModule } from "@angular/core"; +import { HttpClientModule } from '@angular/common/http'; import { AppComponent } from "./app.component"; @NgModule({ declarations: [AppComponent], - imports: [BrowserModule], + imports: [BrowserModule, HttpClientModule], bootstrap: [AppComponent] }) -export class AppModule {} +export class AppModule {} \ No newline at end of file