├── .github └── workflows │ ├── credential.json │ └── deploy-clientapp.yaml ├── .gitignore ├── LICENSE ├── README.md ├── SECURITY.md └── src ├── ClientApp ├── .gitignore ├── gatsby-config.js ├── gatsby-ssr.js ├── package-lock.json ├── package.json ├── readme.md └── src │ ├── components │ ├── drone-status.tsx │ └── spinner-basic.tsx │ ├── pages │ ├── 404.tsx │ └── index.tsx │ └── services │ ├── auth.tsx │ ├── config.js │ └── msal.js ├── DroneSimulator ├── DroneSimulator.sln └── Serverless.Simulator │ ├── ObjectPool.cs │ ├── Program.cs │ ├── Serverless.Simulator.csproj │ └── TelemetryGenerator.cs ├── DroneStatus ├── azuredeploy-slots.json ├── dotnet │ ├── DroneStatus.sln │ ├── DroneStatusFunction.Tests │ │ ├── DroneStatusFunction.Tests.csproj │ │ └── GetStatusFunctionFixture.cs │ └── DroneStatusFunctionApp │ │ ├── .gitignore │ │ ├── ClaimsPrincipalAuthorizationExtensions.cs │ │ ├── ClaimsPrincipalParser.cs │ │ ├── DeviceState.cs │ │ ├── DroneStatusFunctionApp.csproj │ │ ├── GetStatusFunction.cs │ │ ├── Program.cs │ │ ├── Properties │ │ ├── serviceDependencies.json │ │ └── serviceDependencies.local.json │ │ ├── host.json │ │ └── local.settings.template.json └── nodejs │ ├── .funcignore │ ├── .gitignore │ ├── host.json │ ├── package-lock.json │ ├── package.json │ ├── src │ └── functions │ │ ├── GetStatusFunction.ts │ │ └── authorization.ts │ └── tsconfig.json ├── DroneTelemetry ├── DroneTelemetry.sln ├── DroneTelemetryFunction.Tests │ ├── DroneTelemetryFunction.Tests.csproj │ └── TelemetryProcessorFixture.cs └── DroneTelemetryFunctionApp │ ├── .gitignore │ ├── DeadLetterMessage.cs │ ├── DeviceState.cs │ ├── DroneTelemetryFunctionApp.csproj │ ├── ITelemetryProcessor.cs │ ├── Program.cs │ ├── Properties │ ├── serviceDependencies.json │ └── serviceDependencies.local.json │ ├── RawTelemetryFunction.cs │ ├── TelemetryProcessor.cs │ ├── host.json │ └── local.settings.template.json ├── TelemetrySerialization ├── Serverless.Serialization.Tests │ ├── SerializationTest.cs │ └── Serverless.Serialization.Tests.csproj ├── Serverless.Serialization │ ├── Model │ │ └── DroneState.cs │ ├── Serverless.Serialization.csproj │ └── Serverless.Serialization │ │ ├── ITelemetrySerializer.cs │ │ ├── TelemetrySerializer.cs │ │ ├── impl │ │ └── protobuf │ │ │ └── ProtobufPayloadSerializer.cs │ │ └── interface │ │ └── IPayloadSerializer.cs └── TelemetrySerialization.sln ├── azuredeploy-apim.bicep ├── azuredeploy-backend-functionapps-v2.bicep ├── azuredeploy-backend-functionapps.bicep ├── readme-backend-functionapps-v2.md └── readme.md /.github/workflows/credential.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ghActionFederatedIdentityCredential", 3 | "issuer": "https://token.actions.githubusercontent.com", 4 | "subject": "repo:/serverless-reference-implementation:ref:refs/heads/main", 5 | "description": "Deploy Client App", 6 | "audiences": [ 7 | "api://AzureADTokenExchange" 8 | ] 9 | } -------------------------------------------------------------------------------- /.github/workflows/deploy-clientapp.yaml: -------------------------------------------------------------------------------- 1 | name: Deploy Drone Client App 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | azureTenantId: 6 | description: "Tenant Id where app identities are located" 7 | required: true 8 | clientAppId: 9 | description: "Client app Id" 10 | required: true 11 | apiAppId: 12 | description: "Api app Id" 13 | required: true 14 | accessTokenScope: 15 | description: "Access token scope required to access the API" 16 | required: true 17 | apiURL: 18 | description: "Api Management URL" 19 | required: true 20 | azureStorageAccountName: 21 | description: "Azure Storage Account Name" 22 | required: true 23 | azureCdnName: 24 | description: "Azure CDN resource name" 25 | required: true 26 | resourceGroupName: 27 | description: "Resource group name" 28 | required: true 29 | default: "rg-severless" 30 | githubBranch: 31 | description: "Repo branch which want to deploy" 32 | required: true 33 | default: "main" 34 | 35 | permissions: 36 | id-token: write 37 | contents: write 38 | 39 | jobs: 40 | deployClientApp: 41 | runs-on: ubuntu-latest 42 | steps: 43 | - name: Check inputs values 44 | run: | 45 | echo "Tenant Id where app identities are located: ${{ github.event.inputs.azureTenantId }}" 46 | echo "Client app Id: ${{ github.event.inputs.clientAppId }}" 47 | echo "Api app Id: ${{ github.event.inputs.apiAppId }}" 48 | echo "Access Token Scope: ${{ github.event.inputs.accessTokenScope }}" 49 | echo "Api URL: ${{ github.event.inputs.apiURL }}" 50 | echo "Azure Storage Account Name: ${{ github.event.inputs.azureStorageAccountName }}" 51 | echo "Azure CDN resource name: ${{ github.event.inputs.azureCdnName }}" 52 | echo "Resource group name: ${{ github.event.inputs.resourceGroupName }}" 53 | echo "Scripts branch: ${{ github.event.inputs.githubBranch }}" 54 | - name: Check out repo 55 | uses: actions/checkout@v3 56 | with: 57 | ref: ${{ github.event.inputs.githubBranch }} 58 | fetch-depth: 0 59 | - name: Install ubuntu package dependencies 60 | run: | 61 | sudo apt-get install brotli --install-suggests --no-install-recommends -q --assume-yes 62 | - name: Configure azure tenant, client and api details 63 | run: | 64 | cd src/ClientApp 65 | cat > .env.production < src/ClientApp/public/version.txt 93 | echo "${{ steps.gitversion.outputs.fullSemVer }}" > src/ClientApp/public/semver.txt 94 | - name: Create Release 95 | id: create_release 96 | uses: actions/create-release@v1 97 | env: 98 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token 99 | with: 100 | tag_name: ${{ steps.gitversion.outputs.fullSemVer }} 101 | release_name: Release ${{ steps.gitversion.outputs.fullSemVer }} 102 | body: | 103 | 'Fabrikam Drone Status App ${{ steps.gitversion.outputs.fullSemVer }}' 104 | draft: true 105 | prerelease: false 106 | # Login into your Azure Subscription using your Azure credentials - make sure the credentials has write permissions for the specific resource group/subscription. The credentials should be stored in GitHub Secrets - (Go to Settings Tab ->Secrets) 107 | - name: 'Az CLI login' 108 | uses: azure/login@v1 109 | with: 110 | client-id: ${{ secrets.AZURE_CLIENT_ID }} 111 | tenant-id: ${{ secrets.AZURE_TENANT_ID }} 112 | subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} 113 | auth-type: SERVICE_PRINCIPAL 114 | - name: Upload to Azure Storage static website hosting and purge Azure CDN endpoint 115 | uses: azure/CLI@v1 116 | with: 117 | inlineScript: | 118 | Folder=$(echo ${{ steps.gitversion.outputs.fullSemVer }} | sed 's/+//g') 119 | az storage blob upload-batch -s "./src/ClientApp/public" --destination "\$web\\$Folder" --account-name ${{ github.event.inputs.azureStorageAccountName }} --content-encoding br --pattern "*.html" --content-type "text/html" --auth-mode login 120 | az storage blob upload-batch -s "./src/ClientApp/public" --destination "\$web\\$Folder" --account-name ${{ github.event.inputs.azureStorageAccountName }} --content-encoding br --pattern "*.js" --content-type "application/javascript" --auth-mode login 121 | az storage blob upload-batch -s "./src/ClientApp/public" --destination "\$web\\$Folder" --account-name ${{ github.event.inputs.azureStorageAccountName }} --content-encoding br --pattern "*.js.map" --content-type "application/octet-stream" --auth-mode login 122 | az storage blob upload-batch -s "./src/ClientApp/public" --destination "\$web\\$Folder" --account-name ${{ github.event.inputs.azureStorageAccountName }} --content-encoding br --pattern "*.json" --content-type "application/json" --auth-mode login 123 | az storage blob upload-batch -s "./src/ClientApp/public" --destination "\$web\\$Folder" --account-name ${{ github.event.inputs.azureStorageAccountName }} --pattern "*.txt" --content-type "text/plain" --auth-mode login 124 | # target new version 125 | az cdn endpoint update --resource-group ${{ github.event.inputs.resourceGroupName }} --profile-name ${{ github.event.inputs.azureCdnName }} --name ${{ github.event.inputs.azureCdnName }} --origin-path /$Folder 126 | AZURE_CDN_ENDPOINT_HOSTNAME=$(az cdn endpoint show --resource-group ${{ github.event.inputs.resourceGroupName }} --name ${{ github.event.inputs.azureCdnName }} --profile-name ${{ github.event.inputs.azureCdnName }} --query hostName -o tsv) 127 | echo "Azure CDN endpooint host ${AZURE_CDN_ENDPOINT_HOSTNAME}" 128 | 129 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015/2017 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # Visual Studio 2017 auto generated files 33 | Generated\ Files/ 34 | 35 | # MSTest test Results 36 | [Tt]est[Rr]esult*/ 37 | [Bb]uild[Ll]og.* 38 | 39 | # NUNIT 40 | *.VisualState.xml 41 | TestResult.xml 42 | 43 | # Build Results of an ATL Project 44 | [Dd]ebugPS/ 45 | [Rr]eleasePS/ 46 | dlldata.c 47 | 48 | # Benchmark Results 49 | BenchmarkDotNet.Artifacts/ 50 | 51 | # .NET Core 52 | project.lock.json 53 | project.fragment.lock.json 54 | artifacts/ 55 | **/Properties/launchSettings.json 56 | 57 | # StyleCop 58 | StyleCopReport.xml 59 | 60 | # Files built by Visual Studio 61 | *_i.c 62 | *_p.c 63 | *_i.h 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.iobj 68 | *.pch 69 | *.pdb 70 | *.ipdb 71 | *.pgc 72 | *.pgd 73 | *.rsp 74 | *.sbr 75 | *.tlb 76 | *.tli 77 | *.tlh 78 | *.tmp 79 | *.tmp_proj 80 | *.log 81 | *.vspscc 82 | *.vssscc 83 | .builds 84 | *.pidb 85 | *.svclog 86 | *.scc 87 | 88 | # Chutzpah Test files 89 | _Chutzpah* 90 | 91 | # Visual C++ cache files 92 | ipch/ 93 | *.aps 94 | *.ncb 95 | *.opendb 96 | *.opensdf 97 | *.sdf 98 | *.cachefile 99 | *.VC.db 100 | *.VC.VC.opendb 101 | 102 | # Visual Studio profiler 103 | *.psess 104 | *.vsp 105 | *.vspx 106 | *.sap 107 | 108 | # Visual Studio Trace Files 109 | *.e2e 110 | 111 | # TFS 2012 Local Workspace 112 | $tf/ 113 | 114 | # Guidance Automation Toolkit 115 | *.gpState 116 | 117 | # ReSharper is a .NET coding add-in 118 | _ReSharper*/ 119 | *.[Rr]e[Ss]harper 120 | *.DotSettings.user 121 | 122 | # JustCode is a .NET coding add-in 123 | .JustCode 124 | 125 | # TeamCity is a build add-in 126 | _TeamCity* 127 | 128 | # DotCover is a Code Coverage Tool 129 | *.dotCover 130 | 131 | # AxoCover is a Code Coverage Tool 132 | .axoCover/* 133 | !.axoCover/settings.json 134 | 135 | # Visual Studio code coverage results 136 | *.coverage 137 | *.coveragexml 138 | 139 | # NCrunch 140 | _NCrunch_* 141 | .*crunch*.local.xml 142 | nCrunchTemp_* 143 | 144 | # MightyMoose 145 | *.mm.* 146 | AutoTest.Net/ 147 | 148 | # Web workbench (sass) 149 | .sass-cache/ 150 | 151 | # Installshield output folder 152 | [Ee]xpress/ 153 | 154 | # DocProject is a documentation generator add-in 155 | DocProject/buildhelp/ 156 | DocProject/Help/*.HxT 157 | DocProject/Help/*.HxC 158 | DocProject/Help/*.hhc 159 | DocProject/Help/*.hhk 160 | DocProject/Help/*.hhp 161 | DocProject/Help/Html2 162 | DocProject/Help/html 163 | 164 | # Click-Once directory 165 | publish/ 166 | 167 | # Publish Web Output 168 | *.[Pp]ublish.xml 169 | *.azurePubxml 170 | # Note: Comment the next line if you want to checkin your web deploy settings, 171 | # but database connection strings (with potential passwords) will be unencrypted 172 | *.pubxml 173 | *.publishproj 174 | 175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 176 | # checkin your Azure Web App publish settings, but sensitive information contained 177 | # in these scripts will be unencrypted 178 | PublishScripts/ 179 | 180 | # NuGet Packages 181 | *.nupkg 182 | # The packages folder can be ignored because of Package Restore 183 | **/[Pp]ackages/* 184 | # except build/, which is used as an MSBuild target. 185 | !**/[Pp]ackages/build/ 186 | # Uncomment if necessary however generally it will be regenerated when needed 187 | #!**/[Pp]ackages/repositories.config 188 | # NuGet v3's project.json files produces more ignorable files 189 | *.nuget.props 190 | *.nuget.targets 191 | 192 | # Microsoft Azure Build Output 193 | csx/ 194 | *.build.csdef 195 | 196 | # Microsoft Azure Emulator 197 | ecf/ 198 | rcf/ 199 | 200 | # Windows Store app package directories and files 201 | AppPackages/ 202 | BundleArtifacts/ 203 | Package.StoreAssociation.xml 204 | _pkginfo.txt 205 | *.appx 206 | 207 | # Visual Studio cache files 208 | # files ending in .cache can be ignored 209 | *.[Cc]ache 210 | # but keep track of directories ending in .cache 211 | !*.[Cc]ache/ 212 | 213 | # Others 214 | ClientBin/ 215 | ~$* 216 | *~ 217 | *.dbmdl 218 | *.dbproj.schemaview 219 | *.jfm 220 | *.pfx 221 | *.publishsettings 222 | orleans.codegen.cs 223 | 224 | # Including strong name files can present a security risk 225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 226 | #*.snk 227 | 228 | # Since there are multiple workflows, uncomment next line to ignore bower_components 229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 230 | #bower_components/ 231 | 232 | # RIA/Silverlight projects 233 | Generated_Code/ 234 | 235 | # Backup & report files from converting an old project file 236 | # to a newer Visual Studio version. Backup files are not needed, 237 | # because we have git ;-) 238 | _UpgradeReport_Files/ 239 | Backup*/ 240 | UpgradeLog*.XML 241 | UpgradeLog*.htm 242 | ServiceFabricBackup/ 243 | *.rptproj.bak 244 | 245 | # SQL Server files 246 | *.mdf 247 | *.ldf 248 | *.ndf 249 | 250 | # Business Intelligence projects 251 | *.rdl.data 252 | *.bim.layout 253 | *.bim_*.settings 254 | *.rptproj.rsuser 255 | 256 | # Microsoft Fakes 257 | FakesAssemblies/ 258 | 259 | # GhostDoc plugin setting file 260 | *.GhostDoc.xml 261 | 262 | # Node.js Tools for Visual Studio 263 | .ntvs_analysis.dat 264 | node_modules/ 265 | 266 | # Visual Studio 6 build log 267 | *.plg 268 | 269 | # Visual Studio 6 workspace options file 270 | *.opt 271 | 272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 273 | *.vbw 274 | 275 | # Visual Studio LightSwitch build output 276 | **/*.HTMLClient/GeneratedArtifacts 277 | **/*.DesktopClient/GeneratedArtifacts 278 | **/*.DesktopClient/ModelManifest.xml 279 | **/*.Server/GeneratedArtifacts 280 | **/*.Server/ModelManifest.xml 281 | _Pvt_Extensions 282 | 283 | # Paket dependency manager 284 | .paket/paket.exe 285 | paket-files/ 286 | 287 | # FAKE - F# Make 288 | .fake/ 289 | 290 | # JetBrains Rider 291 | .idea/ 292 | *.sln.iml 293 | 294 | # CodeRush 295 | .cr/ 296 | 297 | # Python Tools for Visual Studio (PTVS) 298 | __pycache__/ 299 | *.pyc 300 | 301 | # Cake - Uncomment if you are using it 302 | # tools/** 303 | # !tools/packages.config 304 | 305 | # Tabs Studio 306 | *.tss 307 | 308 | # Telerik's JustMock configuration file 309 | *.jmconfig 310 | 311 | # BizTalk build output 312 | *.btp.cs 313 | *.btm.cs 314 | *.odx.cs 315 | *.xsd.cs 316 | 317 | # OpenCover UI analysis results 318 | OpenCover/ 319 | 320 | # Azure Stream Analytics local run output 321 | ASALocalRun/ 322 | 323 | # MSBuild Binary and Structured Log 324 | *.binlog 325 | 326 | # NVidia Nsight GPU debugger configuration file 327 | *.nvuser 328 | 329 | # MFractors (Xamarin productivity tool) working folder 330 | .mfractor/ 331 | 332 | ## VS Code 333 | .vscode 334 | 335 | # Azure functions tools for VS Code 336 | local.settings.json -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Microsoft patterns & practices 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Drone Delivery Serverless 2 | 3 | This project contains a reference implementation for two serverless application architectures. 4 | 5 | **Serverless web application** 6 | 7 | ![](https://learn.microsoft.com/azure/architecture/reference-architectures/serverless/_images/serverless-web-app.png) 8 | 9 | The application serves static content from Azure Blob Storage, and implements an API using Azure Functions. The API reads data from Cosmos DB and returns the results to the web app. 10 | 11 | **Serverless event processing** 12 | 13 | ![](https://learn.microsoft.com/azure/architecture/reference-architectures/serverless/_images/serverless-event-processing.png) 14 | 15 | The application ingests a stream of data, processes the data, and writes the results to a back-end database (Cosmos DB). 16 | 17 | For more information about these architectures, including guidance about best practices, see the following articles in the Azure Architecture Center: 18 | 19 | - [Serverless web application](https://learn.microsoft.com/azure/architecture/reference-architectures/serverless/web-app) 20 | 21 | - [Serverless event processing using Azure Functions](https://learn.microsoft.com/azure/architecture/reference-architectures/serverless/event-processing) 22 | 23 | 24 | ## Deployment 25 | 26 | Follow [steps here](./src/readme.md) to deploy this reference implementation. 27 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), and [Xamarin](https://github.com/xamarin). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd). 40 | 41 | -------------------------------------------------------------------------------- /src/ClientApp/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # dotenv environment variables file 55 | .env 56 | 57 | # gatsby files 58 | .cache/ 59 | public 60 | 61 | # Mac files 62 | .DS_Store 63 | 64 | # Yarn 65 | yarn-error.log 66 | .pnp/ 67 | .pnp.js 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | -------------------------------------------------------------------------------- /src/ClientApp/gatsby-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | siteMetadata: { 3 | title: `Fabrikam Drone Status`, 4 | description: `Fabrikam Drone status is a SPA static website deployed to Azure Blob storage with Azure CDN`, 5 | author: `@mspnp`, 6 | }, 7 | plugins: [`gatsby-plugin-typescript`], 8 | } -------------------------------------------------------------------------------- /src/ClientApp/gatsby-ssr.js: -------------------------------------------------------------------------------- 1 | import { Stylesheet, InjectionMode } from "@uifabric/merge-styles" 2 | import { renderStatic } from "@uifabric/merge-styles/lib/server" 3 | import { renderToString } from "react-dom/server" 4 | import React from "react" 5 | 6 | export const replaceRenderer = ({ 7 | bodyComponent, 8 | replaceBodyHTMLString, 9 | setHeadComponents, 10 | }) => { 11 | const { html, css } = renderStatic(() => { 12 | return renderToString(bodyComponent) 13 | }) 14 | 15 | replaceBodyHTMLString(html) 16 | 17 | setHeadComponents([