├── .github └── workflows │ ├── deploy-aca-revision-and-traffic-management.yaml │ └── deploy-aks-store-on-aca.yaml ├── .gitignore ├── LICENSE ├── README.md ├── aca-nginx ├── README.md ├── main.bicep ├── modules │ ├── aca-environment.bicep │ ├── aca-routable-apps.bicep │ ├── common.bicep │ ├── default.conf │ ├── keyvault.bicep │ └── network.bicep └── parameters │ ├── dev.bicepparam │ └── prod.bicepparam ├── aca-revision-and-traffic-management ├── README.md ├── main.bicep ├── modules │ ├── aca-common.bicep │ ├── aca-public-apps.bicep │ ├── azure-monitor.bicep │ └── common.bicep └── parameters │ ├── dev.bicepparam │ └── prod.bicepparam ├── aca-with-windows-on-aci ├── README.md ├── main.bicep ├── modules │ └── common.bicep └── parameters │ ├── dev.bicepparam │ └── prod.bicepparam ├── aks-store-on-aca ├── README.md ├── functions.bicep ├── main.bicep ├── modules │ ├── aca-common.bicep │ ├── aca-internal-apps.bicep │ ├── aca-public-apps.bicep │ ├── ai.bicep │ ├── azure-monitor.bicep │ ├── common.bicep │ ├── dns.bicep │ ├── keyvault.bicep │ ├── network.bicep │ ├── rabbitmq_enabled_plugins │ ├── storeAdminNginx.conf │ ├── storeFrontNginx.conf │ └── virtual-network-links.bicep └── parameters │ ├── dev.bicepparam │ └── prod.bicepparam └── static └── images └── aks-store-on-aca-architecture.png /.github/workflows/deploy-aca-revision-and-traffic-management.yaml: -------------------------------------------------------------------------------- 1 | # This workflow provisions all the necessary resources for the demo application from aca-revision-and-traffic-management folder. 2 | # Traffic splitting can be automated further, with revision name generation, health checks and full re-routing to the new version upon successful checks. 3 | # Microsoft has created a useful repository with a sample implementation of this process that can be used for reference and inspiration: https://github.com/Azure-Samples/containerapps-blue-green 4 | name: deploy-aca-revision-and-traffic-management-apps 5 | on: 6 | push: 7 | branches: 8 | - 'main' 9 | paths: 10 | - 'aca-revision-and-traffic-management/**' 11 | - '**/deploy-aca-revision-and-traffic-management-apps.yml' 12 | 13 | workflow_dispatch: 14 | 15 | env: 16 | AZURE_REGION: 'northeurope' 17 | 18 | permissions: 19 | id-token: write 20 | contents: read 21 | 22 | jobs: 23 | deploy-apps-dev: 24 | runs-on: ubuntu-latest 25 | steps: 26 | - name: Checkout repository 27 | uses: actions/checkout@v3 28 | 29 | - name: Login to Azure 30 | uses: azure/login@v1 31 | with: 32 | client-id: ${{ secrets.AZURE_CLIENT_ID }} 33 | tenant-id: ${{ secrets.AZURE_TENANT_ID }} 34 | subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} 35 | 36 | - name: Deploy to dev 37 | uses: azure/arm-deploy@v2 38 | with: 39 | scope: 'subscription' 40 | deploymentName: ${{ github.run_number }} 41 | subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }} 42 | template: ${{ github.workspace }}/aca-revision-and-traffic-management/main.bicep 43 | parameters: ${{ github.workspace }}/aca-revision-and-traffic-management/parameters/dev.bicepparam 44 | region: ${{ env.AZURE_REGION }} 45 | -------------------------------------------------------------------------------- /.github/workflows/deploy-aks-store-on-aca.yaml: -------------------------------------------------------------------------------- 1 | # This workflow provisions all the necessary resources for the demo application from aks-store-on-aca folder. 2 | name: deploy-aks-store-on-aca 3 | on: 4 | #push: 5 | #branches: 6 | # - 'main' 7 | #paths: 8 | # - 'aks-store-on-aca/**' 9 | # - '**/deploy-aks-store-on-aca.yml' 10 | 11 | workflow_dispatch: 12 | 13 | env: 14 | AZURE_REGION: 'northeurope' 15 | 16 | permissions: 17 | id-token: write 18 | contents: read 19 | 20 | jobs: 21 | deploy-apps-dev: 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: Checkout repository 25 | uses: actions/checkout@v3 26 | 27 | - name: Login to Azure 28 | uses: azure/login@v1 29 | with: 30 | client-id: ${{ secrets.AZURE_CLIENT_ID }} 31 | tenant-id: ${{ secrets.AZURE_TENANT_ID }} 32 | subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} 33 | 34 | - name: Deploy to dev 35 | uses: azure/arm-deploy@v2 36 | with: 37 | scope: 'subscription' 38 | deploymentName: ${{ github.run_number }} 39 | subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }} 40 | template: ${{ github.workspace }}/aks-store-on-aca/main.bicep 41 | parameters: ${{ github.workspace }}/aks-store-on-aca/parameters/dev.bicepparam 42 | region: ${{ env.AZURE_REGION }} 43 | -------------------------------------------------------------------------------- /.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/main/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.tlog 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 298 | *.vbp 299 | 300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 301 | *.dsw 302 | *.dsp 303 | 304 | # Visual Studio 6 technical files 305 | *.ncb 306 | *.aps 307 | 308 | # Visual Studio LightSwitch build output 309 | **/*.HTMLClient/GeneratedArtifacts 310 | **/*.DesktopClient/GeneratedArtifacts 311 | **/*.DesktopClient/ModelManifest.xml 312 | **/*.Server/GeneratedArtifacts 313 | **/*.Server/ModelManifest.xml 314 | _Pvt_Extensions 315 | 316 | # Paket dependency manager 317 | .paket/paket.exe 318 | paket-files/ 319 | 320 | # FAKE - F# Make 321 | .fake/ 322 | 323 | # CodeRush personal settings 324 | .cr/personal 325 | 326 | # Python Tools for Visual Studio (PTVS) 327 | __pycache__/ 328 | *.pyc 329 | 330 | # Cake - Uncomment if you are using it 331 | # tools/** 332 | # !tools/packages.config 333 | 334 | # Tabs Studio 335 | *.tss 336 | 337 | # Telerik's JustMock configuration file 338 | *.jmconfig 339 | 340 | # BizTalk build output 341 | *.btp.cs 342 | *.btm.cs 343 | *.odx.cs 344 | *.xsd.cs 345 | 346 | # OpenCover UI analysis results 347 | OpenCover/ 348 | 349 | # Azure Stream Analytics local run output 350 | ASALocalRun/ 351 | 352 | # MSBuild Binary and Structured Log 353 | *.binlog 354 | 355 | # NVidia Nsight GPU debugger configuration file 356 | *.nvuser 357 | 358 | # MFractors (Xamarin productivity tool) working folder 359 | .mfractor/ 360 | 361 | # Local History for Visual Studio 362 | .localhistory/ 363 | 364 | # Visual Studio History (VSHistory) files 365 | .vshistory/ 366 | 367 | # BeatPulse healthcheck temp database 368 | healthchecksdb 369 | 370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 371 | MigrationBackup/ 372 | 373 | # Ionide (cross platform F# VS Code tools) working folder 374 | .ionide/ 375 | 376 | # Fody - auto-generated XML schema 377 | FodyWeavers.xsd 378 | 379 | # VS Code files for those working on multiple tools 380 | .vscode/* 381 | !.vscode/settings.json 382 | !.vscode/tasks.json 383 | !.vscode/launch.json 384 | !.vscode/extensions.json 385 | *.code-workspace 386 | 387 | # Local History for Visual Studio Code 388 | .history/ 389 | 390 | # Windows Installer files from build outputs 391 | *.cab 392 | *.msi 393 | *.msix 394 | *.msm 395 | *.msp 396 | 397 | # JetBrains Rider 398 | *.sln.iml 399 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Azure Container Apps - Demos and useful resources 2 | 3 | This repository contains the source code for different use cases of implementation of Azure Container Apps. Some of these use cases are used for demos in [From Day Zero to Production with Azure Container Apps](https://www.youtube.com/live/yAtMgufv7Aw?si=vtQ6ziOYhasNKuyr) technical session presented by Kristina Devochko. Long-term plan is to include additional useful resources in this repo, like links to blog posts and other helpful content related to all things Azure Container Apps. 4 | 5 | If there are scenarios that are not available in this repository that you would like to see an example implementation of, you can request it by submitting an [issue](https://github.com/guidemetothemoon/azure-container-apps-lab/issues/new), and I will do my best to make it happen😊 6 | 7 | Repository is improved continuously and currently includes four use cases that can be found in the respective folders: 8 | 9 | * (Work In Progress) ```aca-nginx``` folder contains Bicep code for implementing path-based routing between Azure Container Apps, where NGINX is running as a separate container app and acts as a proxy server, routing traffic according to the configured paths, to the other container apps. 10 | 11 | * [aca-revision-and-traffic-management](aca-revision-and-traffic-management/) folder contains a simple Hello World container app that has multiple revision mode configured, which can be used to see revisions and traffic (traffic splitting for blue-green deployment) management in action, once changes are made to the application. 12 | 13 | * (Work In Progress) ```aca-with-windows-on-aci``` folder contains a use case where some applications require Windows containers and are running in Azure Container Instances while the rest of the applications are running as Linux containers in Azure Container Apps. 14 | 15 | * [aks-store-on-aca](aks-store-on-aca/) folder contains implementation of [aks-store-demo](https://github.com/Azure-Samples/aks-store-demo) but on Azure Container Apps, with a configuration that's closer to a production scenario, including security hardening and proper configuration of dependent managed services. 16 | 17 | All use cases are implemented with infrastructure-as-code with Bicep and are directly deployable. Deployment parameters can be adjusted as per your need and are located in Bicep parameter files in ```parameters``` folder in every use case's root folder. 18 | 19 | If you would like to test out resource provisioning with CI/CD, and example of provisioning ```aca-revision-and-traffic-management``` scenario with GitHub Actions workflow, template code is available in [.github/workflows](.github/workflows/deploy-aca-revision-and-traffic-management.yaml) folder at the root of this repo. 20 | 21 | ## Additional reading material 22 | 23 | Following links can be very useful to continue your journey in learning about Azure Container Apps: 24 | 25 | * [Microsoft's documentation on Azure Container Apps](https://learn.microsoft.com/en-us/azure/container-apps) 26 | * [GitHub repository for Azure Container Apps issues and roadmap](https://github.com/microsoft/azure-container-apps​) 27 | * [Azure Container Apps Roadmap](https://github.com/orgs/microsoft/projects/540) 28 | * [How to analyze Azure Container Apps cost](https://github.com/microsoft/azure-container-apps/wiki/Analyze-your-ACA-Bill​) 29 | * [Azure landing zone accelerator for Azure Container Apps](https://techcommunity.microsoft.com/t5/apps-on-azure-blog/announcing-landing-zone-accelerator-for-azure-container-apps​) 30 | * [Path and hostname-based routing in Azure Container Apps with NGINX](https://techcommunity.microsoft.com/t5/apps-on-azure-blog/path-and-hostname-based-routing-in-azure-container-apps-with/ba-p/4068923) 31 | -------------------------------------------------------------------------------- /aca-nginx/README.md: -------------------------------------------------------------------------------- 1 | # TODO 2 | -------------------------------------------------------------------------------- /aca-nginx/main.bicep: -------------------------------------------------------------------------------- 1 | param location string = resourceGroup().location 2 | 3 | param tags object = { 4 | app: 'chaos-nyan-cat' 5 | environment: 'development' 6 | project: 'azure-container-apps-lab' 7 | } 8 | 9 | var vnetName = 'aca-chaos-nyan-cat' 10 | 11 | module vnet 'modules/network.bicep' = { 12 | name: 'vnet' 13 | scope: resourceGroup() 14 | params: { 15 | location: location 16 | tags: tags 17 | vnetAddressSpace: '172.16.0.0/21' 18 | vnetName: vnetName 19 | } 20 | } 21 | 22 | module keyvault 'modules/keyvault.bicep' = { 23 | name: 'keyvault' 24 | scope: resourceGroup() 25 | params: { 26 | location: location 27 | tags: tags 28 | } 29 | } 30 | 31 | module common 'modules/common.bicep' = { 32 | name: 'common' 33 | scope: resourceGroup() 34 | params: { 35 | keyVaultName: keyvault.outputs.keyVaultName 36 | location: location 37 | tags: tags 38 | } 39 | dependsOn: [keyvault] 40 | } 41 | 42 | resource commonKeyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = { 43 | name: keyvault.outputs.keyVaultName 44 | } 45 | 46 | module acaenvironment 'modules/aca-environment.bicep' = { 47 | name: 'aca-environment' 48 | params: { 49 | acaEnvironmentName: 'aca-environment' 50 | acaSubnetId: vnet.outputs.acaSubnetId 51 | location: location 52 | logAnalyticsCustomerId: common.outputs.logAnalyticsCustomerId 53 | logAnalyticsPrimarySharedKey: commonKeyVault.getSecret(common.outputs.logAnalyticsPrimarySharedKey) 54 | tags: tags 55 | } 56 | dependsOn: [common, vnet] 57 | } 58 | 59 | module aca 'modules/aca-routable-apps.bicep' = { 60 | name: 'aca' 61 | scope: resourceGroup() 62 | params: { 63 | acaEnvironmentId: acaenvironment.outputs.environmentId 64 | location: location 65 | managedIdentityId: keyvault.outputs.managedIdentityId 66 | tags: tags 67 | } 68 | dependsOn: [acaenvironment] 69 | } 70 | -------------------------------------------------------------------------------- /aca-nginx/modules/aca-environment.bicep: -------------------------------------------------------------------------------- 1 | param acaEnvironmentName string 2 | param acaSubnetId string 3 | param location string 4 | param logAnalyticsCustomerId string 5 | param tags object 6 | 7 | @secure() 8 | param logAnalyticsPrimarySharedKey string 9 | 10 | resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' = { 11 | location: location 12 | name: acaEnvironmentName 13 | properties: { 14 | appLogsConfiguration: { 15 | destination: 'log-analytics' 16 | logAnalyticsConfiguration: { 17 | customerId: logAnalyticsCustomerId 18 | sharedKey: logAnalyticsPrimarySharedKey 19 | } 20 | } 21 | vnetConfiguration: { 22 | infrastructureSubnetId: acaSubnetId 23 | } 24 | } 25 | tags: tags 26 | } 27 | 28 | output environmentId string = containerAppEnvironment.id 29 | -------------------------------------------------------------------------------- /aca-nginx/modules/aca-routable-apps.bicep: -------------------------------------------------------------------------------- 1 | param acaEnvironmentId string 2 | param backendContainerName string = 'backend-chaos-nyan-cat' 3 | param frontendContainerName string = 'frontend-chaos-nyan-cat' 4 | param managedIdentityId string 5 | param location string 6 | param tags object 7 | 8 | var rawNginxConf = loadTextContent('default.conf') 9 | var nginxConf = replace(rawNginxConf, 'BACKEND_FQDN', backend.name) 10 | //var nginxConf = replace(rawNginxConf, 'BACKEND_FQDN', backend.properties.latestRevisionFqdn) 11 | 12 | resource frontend 'Microsoft.App/containerApps@2023-05-01' = { 13 | name: frontendContainerName 14 | location: location 15 | identity: { 16 | type: 'UserAssigned' 17 | userAssignedIdentities: { 18 | '${managedIdentityId}' : {} 19 | } 20 | } 21 | properties: { 22 | managedEnvironmentId: acaEnvironmentId 23 | configuration: { 24 | secrets: [ 25 | { 26 | name: 'nginx-conf' 27 | value: nginxConf 28 | } 29 | ] 30 | ingress: { 31 | external: true 32 | targetPort: 80 33 | transport: 'http' 34 | clientCertificateMode: 'require' 35 | } 36 | } 37 | template: { 38 | containers: [ 39 | { 40 | image: 'guidemetothemoon/kube-nyan-cat:latest' 41 | volumeMounts: [ 42 | { 43 | mountPath: '/etc/nginx/conf.d/' 44 | volumeName: 'nginx-conf' 45 | } 46 | ] 47 | name: frontendContainerName 48 | resources: { 49 | cpu: json('0.25') 50 | memory: '0.5Gi' 51 | } 52 | probes: [ 53 | { 54 | type: 'liveness' 55 | httpGet: { 56 | path: '/' 57 | port: 80 58 | } 59 | initialDelaySeconds: 20 60 | periodSeconds: 3 61 | failureThreshold: 3 62 | } 63 | { 64 | type: 'readiness' 65 | tcpSocket: { 66 | port: 80 67 | } 68 | initialDelaySeconds: 10 69 | periodSeconds: 3 70 | failureThreshold: 3 71 | } 72 | { 73 | type: 'startup' 74 | httpGet: { 75 | path: '/' 76 | port: 80 77 | } 78 | initialDelaySeconds: 3 79 | periodSeconds: 3 80 | failureThreshold: 3 81 | } 82 | ] 83 | } 84 | ] 85 | scale: { 86 | minReplicas: 1 87 | maxReplicas: 2 88 | } 89 | volumes: [ 90 | { 91 | name: 'nginx-conf' 92 | storageType: 'Secret' 93 | secrets: [ 94 | { 95 | secretRef: 'nginx-conf' 96 | path: 'default.conf' 97 | } 98 | ] 99 | } 100 | ] 101 | } 102 | } 103 | 104 | tags: tags 105 | } 106 | 107 | resource backend 'Microsoft.App/containerApps@2023-05-01' = { 108 | name: backendContainerName 109 | location: location 110 | identity: { 111 | type: 'UserAssigned' 112 | userAssignedIdentities: { 113 | '${managedIdentityId}' : {} 114 | } 115 | } 116 | properties: { 117 | managedEnvironmentId: acaEnvironmentId 118 | configuration: { 119 | ingress: { 120 | external: false 121 | targetPort: 80 122 | transport: 'http' 123 | allowInsecure: true 124 | clientCertificateMode: 'require' 125 | } 126 | } 127 | template: { 128 | containers: [ 129 | { 130 | image: 'guidemetothemoon/kube-nyan-cat:latest' 131 | name: backendContainerName 132 | resources: { 133 | cpu: json('0.25') 134 | memory: '0.5Gi' 135 | } 136 | probes: [ 137 | { 138 | type: 'liveness' 139 | httpGet: { 140 | path: '/' 141 | port: 80 142 | } 143 | initialDelaySeconds: 20 144 | periodSeconds: 3 145 | failureThreshold: 3 146 | } 147 | { 148 | type: 'readiness' 149 | tcpSocket: { 150 | port: 80 151 | } 152 | initialDelaySeconds: 10 153 | periodSeconds: 3 154 | failureThreshold: 3 155 | } 156 | { 157 | type: 'startup' 158 | httpGet: { 159 | path: '/' 160 | port: 80 161 | } 162 | initialDelaySeconds: 3 163 | periodSeconds: 3 164 | failureThreshold: 3 165 | } 166 | ] 167 | } 168 | ] 169 | scale: { 170 | minReplicas: 1 171 | maxReplicas: 2 172 | } 173 | } 174 | } 175 | 176 | tags: tags 177 | } 178 | -------------------------------------------------------------------------------- /aca-nginx/modules/common.bicep: -------------------------------------------------------------------------------- 1 | param appInsightsName string = 'appi-${uniqueString(resourceGroup().id)}' 2 | param keyVaultName string 3 | param location string 4 | param logAnalyticsName string = 'la-${uniqueString(resourceGroup().id)}' 5 | param tags object 6 | 7 | resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2022-10-01' = { 8 | name: logAnalyticsName 9 | location: location 10 | properties: { 11 | retentionInDays: 30 12 | sku: { 13 | name: 'PerGB2018' 14 | } 15 | } 16 | tags: tags 17 | } 18 | 19 | resource appInsights 'Microsoft.Insights/components@2020-02-02' = { 20 | name: appInsightsName 21 | location: location 22 | kind: 'web' 23 | properties: { 24 | Application_Type: 'web' 25 | WorkspaceResourceId:logAnalytics.id 26 | RetentionInDays: 30 27 | } 28 | tags: tags 29 | } 30 | 31 | resource keyVaultShared 'Microsoft.KeyVault/vaults@2022-07-01' existing = { 32 | name: keyVaultName 33 | } 34 | 35 | resource logAnalyticsKeySecret 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = { 36 | parent: keyVaultShared 37 | name: 'logAnalyticsKey' 38 | properties: { 39 | value: logAnalytics.listKeys().primarySharedKey 40 | } 41 | } 42 | 43 | output logAnalyticsWorkspaceId string = logAnalytics.id 44 | output logAnalyticsCustomerId string = logAnalytics.properties.customerId 45 | output logAnalyticsPrimarySharedKey string = logAnalyticsKeySecret.name 46 | -------------------------------------------------------------------------------- /aca-nginx/modules/default.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | 4 | # Set the root directory 5 | root /usr/share/nginx/html; 6 | 7 | # Serve index.html for all requests 8 | location / { 9 | try_files $uri $uri/ /index.html; 10 | } 11 | 12 | location /test { 13 | proxy_pass http://BACKEND_FQDN/; 14 | proxy_http_version 1.1; 15 | } 16 | 17 | # Enable gzip compression 18 | gzip on; 19 | gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; 20 | 21 | # Disable caching for HTML files 22 | location ~* \.html$ { 23 | expires -1; 24 | } 25 | 26 | # Enable caching for other files 27 | location ~* \.(jpg|jpeg|gif|png|svg|ico|css|js)$ { 28 | expires 30d; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /aca-nginx/modules/keyvault.bicep: -------------------------------------------------------------------------------- 1 | param keyVaultName string = 'kv-${uniqueString(resourceGroup().id)}' 2 | param location string 3 | param tags object 4 | param tenantId string = subscription().tenantId 5 | 6 | param keyVaultSku object = { 7 | name: 'standard' 8 | family: 'A' 9 | } 10 | 11 | resource keyVault 'Microsoft.KeyVault/vaults@2021-10-01' = { 12 | name: keyVaultName 13 | location: location 14 | properties: { 15 | tenantId: tenantId 16 | enabledForTemplateDeployment: true 17 | enableRbacAuthorization: true 18 | enablePurgeProtection: true 19 | softDeleteRetentionInDays: 7 20 | sku: keyVaultSku 21 | } 22 | tags: tags 23 | } 24 | 25 | resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { 26 | name: 'kv-uaid' 27 | location: location 28 | tags: tags 29 | } 30 | 31 | resource keyVaultSecretsOfficerRoleDefinition 'Microsoft.Authorization/roleDefinitions@2018-01-01-preview' existing = { 32 | scope: subscription() 33 | name: 'b86a8fe4-44ce-4948-aee5-eccb2c155cd7' 34 | } 35 | 36 | resource keyVaultroleAssignment 'Microsoft.Authorization/roleAssignments@2020-10-01-preview' = { 37 | name: guid(keyVault.id, managedIdentity.id, keyVaultSecretsOfficerRoleDefinition.id) 38 | scope: keyVault 39 | properties: { 40 | roleDefinitionId: keyVaultSecretsOfficerRoleDefinition.id 41 | principalId: managedIdentity.properties.principalId 42 | principalType: 'ServicePrincipal' 43 | } 44 | } 45 | 46 | output keyVaultId string = keyVault.id 47 | output keyVaultName string = keyVault.name 48 | output keyVaultUri string = keyVault.properties.vaultUri 49 | output managedIdentityId string = managedIdentity.id 50 | -------------------------------------------------------------------------------- /aca-nginx/modules/network.bicep: -------------------------------------------------------------------------------- 1 | param location string 2 | param tags object 3 | param vnetAddressSpace string 4 | param vnetName string 5 | 6 | var subnets = [ 7 | { 8 | name: 'snet-aca-chaos-nyan-cat' 9 | subnetPrefix: '172.16.0.0/23' 10 | } 11 | ] 12 | 13 | resource vnet 'Microsoft.Network/virtualNetworks@2023-04-01' = { 14 | name: 'vnet-${vnetName}' 15 | location: location 16 | properties: { 17 | addressSpace: { 18 | addressPrefixes: [ 19 | vnetAddressSpace 20 | ] 21 | } 22 | subnets: [ 23 | for subnet in subnets: { 24 | name: subnet.name 25 | properties: { 26 | addressPrefix: subnet.subnetPrefix 27 | serviceEndpoints: [ 28 | { 29 | service: 'Microsoft.KeyVault' 30 | locations: [ 31 | location 32 | ] 33 | } 34 | ] 35 | } 36 | } 37 | ] 38 | } 39 | tags: tags 40 | } 41 | 42 | output vnetId string = vnet.id 43 | output vnetName string = vnet.name 44 | output acaSubnetName string = vnet.properties.subnets[0].name 45 | output acaSubnetId string = vnet.properties.subnets[0].id 46 | output acaSubnetIpRange string = vnet.properties.subnets[0].properties.addressPrefix 47 | -------------------------------------------------------------------------------- /aca-nginx/parameters/dev.bicepparam: -------------------------------------------------------------------------------- 1 | using '../main.bicep' 2 | 3 | param acaResourceGroupName = 'rg-aca-nginx-${locationPrefix}-${environment}' 4 | param environment = 'dev' 5 | param location = 'northeurope' 6 | param locationPrefix = 'neu' 7 | 8 | param tags = { 9 | application: 'aca-nginx' 10 | environment: environment 11 | } 12 | 13 | -------------------------------------------------------------------------------- /aca-nginx/parameters/prod.bicepparam: -------------------------------------------------------------------------------- 1 | using '../main.bicep' 2 | 3 | param acaResourceGroupName = 'rg-aca-nginx-${locationPrefix}-${environment}' 4 | param environment = 'prod' 5 | param location = 'northeurope' 6 | param locationPrefix = 'neu' 7 | 8 | param tags = { 9 | application: 'aca-nginx' 10 | environment: environment 11 | } 12 | -------------------------------------------------------------------------------- /aca-revision-and-traffic-management/README.md: -------------------------------------------------------------------------------- 1 | # Revision and traffic management in Azure Container Apps 2 | 3 | This folder contains Bicep code for provisioning a demo application that can be used to see multiple revisions and traffic splitting for Azure Container Apps in action. Demo application itself is a simple Hello World application that was initially created by Microsoft for AKS demos, but why not re-use it for Azure Container Apps as well? 😼 4 | 5 | Implementation includes following modules: 6 | 7 | * [common](modules/common.bicep): includes common, shared resources that are used by other resources in the deployment. For example, managed identities or deployment-specific Azure Policy assignments. 8 | * [azure_monitor](modules/azure-monitor.bicep): includes observability-related resources, like Log Analytics, Application Insights, etc. 9 | * [aca_common](modules/aca-common.bicep): includes resources that are common for Azure Container Apps, like Azure Container Apps environment. 10 | * [public_apps](modules/aca-public-apps.bicep): includes container apps that are publicly accessible. 11 | 12 | ## Deployment instructions 13 | 14 | 1. Deploy code as-is first (after adjusting parameters as per your use case) - initially in [aca-public-apps.bicep](modules/aca-public-apps.bicep) it's defined that application will be deployed in multi-revision mode, but when we start from nothing only one, first, revision will be deployed. Due to that in ```*.bicepparam``` file traffic distribution is configured to send 100% traffic to the latest revision, which will be the app's very first revision. 15 | 16 | 2. Let's make a change to the application to create a new revision - in [aca-public-apps.bicep](modules/aca-public-apps.bicep) update ```TITLE``` environment variable with a new value that can identify new app revision. Next, let's update traffic distribution: 17 | 2.1. Get name of the currently active, first app revision by running following Azure CLI command (update ```resource-group``` parameter with the one defined in the respective ```.bicepparam``` file): ```az containerapp revision list --name aca-hello-world --resource-group --query [0].name -o tsv``` 18 | 2.2. In the respective ```.bicepparam``` file update ```trafficDistribution``` array: update weight number for ```latestRevision``` object - this object represents every new revision that's being provisioned. Uncomment second object and update ```revisionName``` value with the one retrieved in step 2.1. Then update ```weight``` value with the amount of traffic you want to send to the previous/initial revision. **Please note that weight for all revisions combined must be 100.** 19 | 3. Re-provision resources with the new changes. Go to the public URL of the app and do a bunch of refreshes to verify that traffic is now routed to both versions/revisions of the application. 20 | 21 | ### GitHub Actions Workflow 22 | 23 | Example of a GitHub Actions Workflow has been set up for you to use in your own repository to provision resources in this folder. Workflow is available in [deploy-aca-revision-and-traffic-management.yaml](../.github/workflows/deploy-aca-revision-and-traffic-management.yaml) file in the root of the repository. Please note that you need to configure GitHub secrets for the workflow to be able to log into your Azure subscription and provision resources to it. I would recommend setting up a managed identity with federated credential for this purpose and give it Contributor permissions on the subscription level (resource group provisioning is part of the Bicep code, but you can also provision resource group outside of this deployment and then only give the identity permissions on the respective resource group's level). 24 | 25 | Please refer following Microsoft documentation on how to set up managed identity with federated credentials for usage in GitHub Actions worfklow: [Use GitHub Actions to connect to Azure](https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Clinux) 26 | -------------------------------------------------------------------------------- /aca-revision-and-traffic-management/main.bicep: -------------------------------------------------------------------------------- 1 | targetScope='subscription' 2 | 3 | @description('Resource group name where all resources for the deployment will be provisioned.') 4 | param acaResourceGroupName string 5 | 6 | @description('Environment name (dev, test, prod)') 7 | param environment string 8 | 9 | @description('Location where resources will be provisioned') 10 | param location string 11 | 12 | @description('Tags to be applied to all resources in this deployment') 13 | param tags object 14 | 15 | @description('Array that represents desired traffic distribution between container apps revisions') 16 | param trafficDistribution array 17 | 18 | resource rg 'Microsoft.Resources/resourceGroups@2022-09-01' = { 19 | name: acaResourceGroupName 20 | location: location 21 | } 22 | 23 | @description('Module that provisions common resources that will be re-used by other resources in the deployment, like managed identities') 24 | module common 'modules/common.bicep' = { 25 | name: 'common-resources' 26 | scope: rg 27 | params: { 28 | environment: environment 29 | location: location 30 | tags: tags 31 | } 32 | } 33 | 34 | @description('Module that provisions Azure Monitor resources, like Log Analytics workspace and Application Insights.') 35 | module azure_monitor 'modules/azure-monitor.bicep' = { 36 | name: 'azure-monitor' 37 | scope: rg 38 | params: { 39 | environment: environment 40 | location: location 41 | managedIdentityId: common.outputs.managedIdentityId 42 | tags: tags 43 | } 44 | } 45 | 46 | @description('Module that provisions common overall resources for Azure Container Apps, like Azure Container Apps environment.') 47 | module aca_common 'modules/aca-common.bicep' = { 48 | name: 'aca-common' 49 | scope: rg 50 | params: { 51 | location: location 52 | logAnalyticsWorkspaceId: azure_monitor.outputs.logAnalyticsWorkspaceId 53 | managedIdentityId: common.outputs.managedIdentityId 54 | tags: tags 55 | } 56 | } 57 | 58 | @description('Module that provisions publicly accessible applications as Azure Container Apps.') 59 | module public_apps 'modules/aca-public-apps.bicep' = { 60 | name: 'public-apps' 61 | scope: rg 62 | params: { 63 | environmentId: aca_common.outputs.environmentId 64 | location: location 65 | managedIdentityId: common.outputs.managedIdentityId 66 | tags: tags 67 | trafficDistribution: trafficDistribution 68 | } 69 | } 70 | 71 | @description('URL for accessing Hello World application') 72 | output helloWorldUrl string = public_apps.outputs.helloWorldAppUri 73 | -------------------------------------------------------------------------------- /aca-revision-and-traffic-management/modules/aca-common.bicep: -------------------------------------------------------------------------------- 1 | param location string 2 | param logAnalyticsWorkspaceId string 3 | param managedIdentityId string 4 | param tags object 5 | 6 | resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2023-11-02-preview' = { 7 | name: 'cae-aca-hello-world' 8 | location: location 9 | identity: { 10 | type: 'UserAssigned' 11 | userAssignedIdentities: { 12 | '${managedIdentityId}' : {} 13 | } 14 | } 15 | properties: { 16 | appLogsConfiguration: { 17 | /* In this demo Azure Monitor is configured as ACA logs destination: https://learn.microsoft.com/en-us/azure/container-apps/log-options 18 | * If you would like to see how 'Log Analytics' option is configured, please check out ./aks-store-on-aca/modules/aca-common.bicep file 19 | */ 20 | destination: 'azure-monitor' 21 | } 22 | } 23 | tags: tags 24 | } 25 | 26 | @description('Diagnostic setting for the ACA environment that\'s required when Azure Monitor is configured as logs destination.') 27 | resource acaEnvironmentDiagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = { 28 | name: containerAppsEnvironment.name 29 | scope: containerAppsEnvironment 30 | properties: { 31 | workspaceId: logAnalyticsWorkspaceId 32 | logs: [ 33 | { 34 | categoryGroup: 'allLogs' 35 | enabled: true 36 | } 37 | ] 38 | metrics: [ 39 | { 40 | category: 'AllMetrics' 41 | enabled: true 42 | } 43 | ] 44 | } 45 | } 46 | 47 | 48 | output defaultDomain string = containerAppsEnvironment.properties.defaultDomain 49 | output environmentId string = containerAppsEnvironment.id 50 | -------------------------------------------------------------------------------- /aca-revision-and-traffic-management/modules/aca-public-apps.bicep: -------------------------------------------------------------------------------- 1 | param environmentId string 2 | param location string 3 | param managedIdentityId string 4 | param tags object 5 | param trafficDistribution array 6 | 7 | resource helloworld 'Microsoft.App/containerApps@2023-05-02-preview' = { 8 | name: 'aca-hello-world' 9 | location: location 10 | tags: tags 11 | identity: { 12 | type: 'UserAssigned' 13 | userAssignedIdentities: { 14 | '${managedIdentityId}' : {} 15 | } 16 | } 17 | properties: { 18 | managedEnvironmentId: environmentId 19 | configuration: { 20 | ingress: { 21 | external: true 22 | targetPort: 80 23 | transport: 'http' 24 | clientCertificateMode: 'ignore' 25 | traffic: trafficDistribution 26 | } 27 | activeRevisionsMode: 'Multiple' 28 | maxInactiveRevisions: 2 29 | } 30 | template: { 31 | containers: [ 32 | { 33 | image: 'mcr.microsoft.com/azuredocs/aks-helloworld:v1' 34 | name: 'aca-hello-world' 35 | resources: { 36 | cpu: json('0.5') 37 | memory: '1.0Gi' 38 | } 39 | env: [ 40 | { 41 | name: 'TITLE' 42 | value: 'Hello World from Azure Container Apps (ACA)- V2!' 43 | } 44 | ] 45 | probes: [ 46 | { 47 | type: 'Liveness' 48 | httpGet: { 49 | path: '/' 50 | port: 80 51 | } 52 | initialDelaySeconds: 3 53 | periodSeconds: 3 54 | failureThreshold: 5 55 | } 56 | { 57 | type: 'Readiness' 58 | httpGet: { 59 | path: '/' 60 | port: 80 61 | } 62 | initialDelaySeconds: 3 63 | periodSeconds: 3 64 | failureThreshold: 3 65 | } 66 | ] 67 | } 68 | ] 69 | scale: { 70 | minReplicas: 1 71 | } 72 | } 73 | } 74 | } 75 | 76 | output helloWorldAppUri string = 'https://${helloworld.properties.configuration.ingress.fqdn}' 77 | -------------------------------------------------------------------------------- /aca-revision-and-traffic-management/modules/azure-monitor.bicep: -------------------------------------------------------------------------------- 1 | param environment string 2 | param location string 3 | param managedIdentityId string 4 | param tags object 5 | 6 | resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2022-10-01' = { 7 | name: 'log-aca-helloworld-${environment}' 8 | location: location 9 | identity: { 10 | type: 'UserAssigned' 11 | userAssignedIdentities: { 12 | '${managedIdentityId}' : {} 13 | } 14 | } 15 | properties: { 16 | retentionInDays: 30 17 | sku: { 18 | name: 'PerGB2018' 19 | } 20 | } 21 | tags: tags 22 | } 23 | 24 | output logAnalyticsWorkspaceId string = logAnalytics.id 25 | -------------------------------------------------------------------------------- /aca-revision-and-traffic-management/modules/common.bicep: -------------------------------------------------------------------------------- 1 | param environment string 2 | param location string 3 | param tags object 4 | 5 | resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { 6 | name: 'uaid-aca-helloworld-common-${environment}' 7 | location: location 8 | tags: tags 9 | } 10 | 11 | output managedIdentityId string = managedIdentity.id 12 | output managedIdentityName string = managedIdentity.name 13 | -------------------------------------------------------------------------------- /aca-revision-and-traffic-management/parameters/dev.bicepparam: -------------------------------------------------------------------------------- 1 | using '../main.bicep' 2 | 3 | param acaResourceGroupName = 'rg-aca-helloworld-neu-${environment}' 4 | param environment = 'dev' 5 | param location = 'northeurope' 6 | 7 | param tags = { 8 | application: 'aca-revision-traffic-mgmt' 9 | environment: environment 10 | } 11 | param trafficDistribution = [ 12 | { 13 | latestRevision: true 14 | weight: 50 15 | } 16 | { 17 | revisionName: 'aca-hello-world--3h77zdz' 18 | weight: 50 19 | } 20 | ] 21 | 22 | // Command to get revision names: az containerapp revision list --name aca-hello-world --resource-group rg-aca-helloworld-neu-dev --query [].name -o tsv 23 | -------------------------------------------------------------------------------- /aca-revision-and-traffic-management/parameters/prod.bicepparam: -------------------------------------------------------------------------------- 1 | using '../main.bicep' 2 | 3 | param acaResourceGroupName = 'rg-aca-helloworld-neu-${environment}' 4 | param environment = 'prod' 5 | param location = 'northeurope' 6 | 7 | param tags = { 8 | application: 'aca-revision-traffic-mgmt' 9 | environment: environment 10 | } 11 | 12 | param trafficDistribution = [ 13 | { 14 | latestRevision: true 15 | weight: 100 16 | } 17 | /*{ 18 | revisionName: '' 19 | weight: 50 20 | }*/ 21 | ] 22 | 23 | // Command to get revision names: az containerapp revision list --name aca-hello-world --resource-group rg-aca-helloworld-neu-dev --query [].name -o tsv 24 | -------------------------------------------------------------------------------- /aca-with-windows-on-aci/README.md: -------------------------------------------------------------------------------- 1 | # TODO 2 | -------------------------------------------------------------------------------- /aca-with-windows-on-aci/main.bicep: -------------------------------------------------------------------------------- 1 | // TODO 2 | -------------------------------------------------------------------------------- /aca-with-windows-on-aci/modules/common.bicep: -------------------------------------------------------------------------------- 1 | // TODO 2 | -------------------------------------------------------------------------------- /aca-with-windows-on-aci/parameters/dev.bicepparam: -------------------------------------------------------------------------------- 1 | using '../main.bicep' 2 | 3 | param acaResourceGroupName = 'rg-aca-aci-${locationPrefix}-${environment}' 4 | param environment = 'dev' 5 | param location = 'northeurope' 6 | param locationPrefix = 'neu' 7 | 8 | param tags = { 9 | application: 'aca-win-aci' 10 | environment: environment 11 | } 12 | 13 | -------------------------------------------------------------------------------- /aca-with-windows-on-aci/parameters/prod.bicepparam: -------------------------------------------------------------------------------- 1 | using '../main.bicep' 2 | 3 | param acaResourceGroupName = 'rg-aca-aci-${locationPrefix}-${environment}' 4 | param environment = 'prod' 5 | param location = 'northeurope' 6 | param locationPrefix = 'neu' 7 | 8 | param tags = { 9 | application: 'aca-win-aci' 10 | environment: environment 11 | } 12 | -------------------------------------------------------------------------------- /aks-store-on-aca/README.md: -------------------------------------------------------------------------------- 1 | # Implementation of AKS Store Demo App with Azure Container Apps 2 | 3 | This folder contains Bicep code for provisioning [aks-store-demo](https://github.com/Azure-Samples/aks-store-demo), but on Azure Container Apps. Deployment also is created in a manner that's closer to an actual production scenario, including security hardening configuration. 4 | 5 | Below you may find the Azure solution architecture diagram: 6 | 7 | ![Drawing of the Azure solution architecture for store application running in Azure Container Apps](../static/images/aks-store-on-aca-architecture.png) 8 | 9 | Implementation includes following modules: 10 | 11 | * [common](modules/common.bicep): includes common, shared resources that are used by other resources in the deployment. For example, managed identities or deployment-specific Azure Policy assignments. 12 | * [network](modules/network.bicep): includes network-related resources. For example, virtual networks, subnets and network security groups. 13 | * [dns](modules/dns.bicep): includes DNS-related resources. For example, private DNS zones. 14 | * [vnet_links](modules/virtual-network-links.bicep): includes virtual network link resources for mapping of virtual networks with private DNS zones, which is required for the private endpoints to function properly. 15 | * [kv](modules/keyvault.bicep): includes Azure Key Vault resources, with enabled RBAC and configuration for secure access to the resources with private endpoints. 16 | * [azure_monitor](modules/azure-monitor.bicep): includes observability-related resources, like Log Analytics, Application Insights, etc. It also includes Azure Monitor Private Link Scope (AMPLS) and related resources for configuration of secure access to Azure Monitor services. 17 | * [ai](modules/ai.bicep): includes cognitive services, like Azure OpenAI with respective model deployments and configuration for secure access to the resources with private endpoints. 18 | * [aca_common](modules/aca-common.bicep): includes resources that are common for Azure Container Apps, like Azure Container Apps environment and network configuration for secure communication to and between apps. 19 | * [internal_apps](modules/aca-internal-apps.bicep): includes container apps that are not publicly accessible, i.e. internal services. 20 | * [public_apps](modules/aca-public-apps.bicep): includes container apps that are publicly accessible. 21 | 22 | ## Deployment instructions 23 | 24 | Update Bicep parameter files in [parameters](parameters/) folder as per your use case. ***Please note that if you're changing the deployment region for Azure OpenAI service, you need to ensure that the region supports gpt-35-turbo deployment with up to 240 K quota.*** Please refer following Microsoft documentation for additional information: [Model summary table and region availability](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#model-summary-table-and-region-availability). 25 | 26 | Once you've verified parameter values you're ready to deploy resources. You can trigger deployment directly from your IDE (if you have Bicep extension installed), Azure CLI or by forking the repo and utilizing [deploy-aks-store-on-aca.yaml](../.github/workflows/deploy-aks-store-on-aca.yaml) GitHub Actions worfklow. Please note that you need to configure GitHub secrets for the workflow to be able to log into your Azure subscription and provision resources to it. I would recommend setting up a managed identity with federated credential for this purpose and give it Contributor permissions on the subscription level (resource group provisioning is part of the Bicep code, but you can also provision resource group outside of this deployment and then only give the identity permissions on the respective resource group's level). 27 | 28 | Please refer following Microsoft documentation on how to set up managed identity with federated credentials for usage in GitHub Actions worfklow: [Use GitHub Actions to connect to Azure](https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Clinux) 29 | -------------------------------------------------------------------------------- /aks-store-on-aca/functions.bicep: -------------------------------------------------------------------------------- 1 | // Re-used from https://github.com/Azure/bicep/issues/5703#issuecomment-2004230485 2 | 3 | @description('User-defined, re-usable function that can be used to replace multiple strings in a specific string, which is currently not supported out of the box by the replace() function in Bicep.') 4 | @export() 5 | func replaceMultipleStrings(input string, replacements { *: string }) string => reduce( 6 | items(replacements), input, (cur, next) => replace(string(cur), next.key, next.value)) 7 | -------------------------------------------------------------------------------- /aks-store-on-aca/main.bicep: -------------------------------------------------------------------------------- 1 | targetScope='subscription' 2 | 3 | @description('Resource group name where Azure Container Apps resources will be provisioned') 4 | param acaResourceGroupName string 5 | 6 | @description('Resource group name where resources that are shared across different resource group are provisioned') 7 | param commonResourceGroupName string 8 | 9 | @description('Name of the common Azure Key Vault that contains secrets that can\'t be uploaded as part of the Bicep code') 10 | param commonKeyVaultName string 11 | 12 | @description('Environment name (dev, test, prod)') 13 | param environment string 14 | 15 | @description('Location where resources will be provisioned') 16 | param location string 17 | 18 | @description('Prefix for the location name (e.g. "neu" for "northeurope")') 19 | param locationPrefix string 20 | 21 | @description('Location where Azure OpenAI resources will be provisioned') 22 | param openAILocation string 23 | 24 | @description('Subnets for the virtual network used by the Azure Container Apps resources') 25 | param subnets array 26 | 27 | @description('Tags to be applied to all resources in this deployment') 28 | param tags object 29 | 30 | @description('IP range for the virtual network that will be utilized by the Azure Container Apps resources') 31 | param vnetIpRange string 32 | 33 | @description('List of Azure Monitor Private Link Scope (AMPLS) private DNS zones that will be used by the private endpoints in the deployment') 34 | var amplsPrivateDnsZones = [ 35 | 'privatelink.monitor.azure.com' 36 | 'privatelink.oms.opinsights.azure.com' 37 | 'privatelink.ods.opinsights.azure.com' 38 | 'privatelink.agentsvc.azure-automation.net' 39 | 'privatelink.blob.${az.environment().name}' 40 | ] 41 | 42 | @description('List of non-AMPLS private DNS zones that will be used by the private endpoints in the deployment') 43 | var otherPrivateDnsZones = [ 44 | 'privatelink.vaultcore.azure.net' 45 | 'privatelink.openai.azure.com' 46 | ] 47 | 48 | resource keyVaultCommon 'Microsoft.KeyVault/vaults@2022-07-01' existing = { 49 | scope: resourceGroup(commonResourceGroupName) 50 | name: commonKeyVaultName 51 | } 52 | 53 | resource rg 'Microsoft.Resources/resourceGroups@2022-09-01' = { 54 | name: acaResourceGroupName 55 | location: location 56 | } 57 | 58 | @description('Module that provisions common resources that will be re-used by other resources in the deployment, like managed identities') 59 | module common 'modules/common.bicep' = { 60 | name: 'common-resources' 61 | scope: rg 62 | params: { 63 | environment: environment 64 | location: location 65 | tags: tags 66 | } 67 | } 68 | 69 | @description('Module that provisions network-related resources, like virtual network, subnets and network security groups') 70 | module network 'modules/network.bicep' = { 71 | name: 'network-resources' 72 | scope: rg 73 | params: { 74 | environment: environment 75 | location: location 76 | locationPrefix: locationPrefix 77 | subnets: subnets 78 | tags: tags 79 | vnetIpRange: vnetIpRange 80 | } 81 | } 82 | 83 | @description('Module that provisions DNS-related resources, like private DNS zones') 84 | module dns 'modules/dns.bicep' = { 85 | name: 'dns-resources' 86 | scope: rg 87 | params: { 88 | privateDnsZones: union(amplsPrivateDnsZones, otherPrivateDnsZones) 89 | tags: tags 90 | } 91 | } 92 | 93 | @description('Module that provisions virtual network links for mapping respective virtual network resources with the private DNS zones') 94 | module vnet_links 'modules/virtual-network-links.bicep' = [for (zone, i) in union(amplsPrivateDnsZones, otherPrivateDnsZones): { 95 | name: '${zone}-vnetlink-deploy' 96 | scope: rg 97 | params: { 98 | vnetId: network.outputs.vnetId 99 | dnsZoneName: zone 100 | tags: tags 101 | } 102 | dependsOn: [dns] 103 | }] 104 | 105 | @description('Module that provisions Azure Key Vault that will be used by Azure Container Apps, with enabled RBAC and restricted access configuration, including access only through private endpoint.') 106 | module kv 'modules/keyvault.bicep' = { 107 | name: 'key-vault' 108 | scope: rg 109 | params: { 110 | keyVaultDnsZoneName: otherPrivateDnsZones[0] 111 | location: location 112 | managedIdentityName: common.outputs.managedIdentityName 113 | subnetId: network.outputs.acaSubnetId 114 | tags: tags 115 | } 116 | dependsOn: [dns] 117 | } 118 | 119 | @description('Module that provisions Azure Monitor resources, like Log Analytics workspace and Application Insights, including Azure Monitor Private Link Scope (AMPLS) for secure access to observability resources.') 120 | module azure_monitor 'modules/azure-monitor.bicep' = { 121 | name: 'azure-monitor' 122 | scope: rg 123 | params: { 124 | amplsPrivateDnsZones: amplsPrivateDnsZones 125 | environment: environment 126 | keyVaultName: kv.outputs.keyVaultName 127 | location: location 128 | locationPrefix: locationPrefix 129 | managedIdentityId: common.outputs.managedIdentityId 130 | subnetId: network.outputs.acaSubnetId 131 | tags: tags 132 | } 133 | dependsOn: [dns, vnet_links] 134 | } 135 | 136 | resource keyVaultACA 'Microsoft.KeyVault/vaults@2022-07-01' existing = { 137 | name: kv.outputs.keyVaultName 138 | scope: rg 139 | } 140 | 141 | @description('Module that provisions AI-related resources, like Azure OpenAI with respective model deployments, with restricted access configuration, like resource access only through private endpoint.') 142 | module ai 'modules/ai.bicep' = { 143 | name: 'ai' 144 | scope: rg 145 | params: { 146 | openAIDnsZoneName: otherPrivateDnsZones[1] 147 | keyVaultName: kv.outputs.keyVaultName 148 | location: location 149 | managedIdentityId: common.outputs.managedIdentityId 150 | openAILocation: openAILocation 151 | subnetId: network.outputs.acaSubnetId 152 | tags: tags 153 | } 154 | dependsOn: [dns] 155 | } 156 | 157 | @description('Module that provisions common overall resources for Azure Container Apps, like Azure Container Apps environment, with restricted access configuration, like resource access only for defined subnets and ports.') 158 | module aca_common 'modules/aca-common.bicep' = { 159 | name: 'aca-common' 160 | scope: rg 161 | params: { 162 | location: location 163 | logAnalyticsCustomerId: azure_monitor.outputs.logAnalyticsCustomerId 164 | logAnalyticsKey: keyVaultACA.getSecret(azure_monitor.outputs.logAnalyticsKey) 165 | managedIdentityId: common.outputs.managedIdentityId 166 | nsgName: network.outputs.nsgName 167 | subnetId: network.outputs.acaSubnetId 168 | tags: tags 169 | } 170 | } 171 | 172 | @description('Module that provisions internal applications as Azure Container Apps.') 173 | module internal_apps 'modules/aca-internal-apps.bicep' = { 174 | name: 'internal-apps' 175 | scope: rg 176 | params: { 177 | environmentId: aca_common.outputs.environmentId 178 | location: location 179 | managedIdentityId: common.outputs.managedIdentityId 180 | openAIDeploymentName: ai.outputs.openAIDeploymentName 181 | openAIEndpointSecretUri: ai.outputs.openAIEndpointSecretUri 182 | openAIKeySecretUri: ai.outputs.openAIKeySecretUri 183 | queueUsername: keyVaultCommon.getSecret('queue-username') 184 | queuePass: keyVaultCommon.getSecret('queue-password') 185 | subnetIpRange: network.outputs.acaSubnetIpRange 186 | tags: tags 187 | } 188 | } 189 | 190 | @description('Module that provisions publicly accessible applications as Azure Container Apps.') 191 | module public_apps 'modules/aca-public-apps.bicep' = { 192 | name: 'public-apps' 193 | scope: rg 194 | params: { 195 | environmentId: aca_common.outputs.environmentId 196 | location: location 197 | makelineServiceUri: internal_apps.outputs.makelineServiceUri 198 | managedIdentityId: common.outputs.managedIdentityId 199 | orderServiceUri: internal_apps.outputs.orderServiceUri 200 | productServiceUri: internal_apps.outputs.productServiceUri 201 | storeAdminAuthClientId: keyVaultCommon.getSecret('store-admin-auth-client-id') 202 | storeAdminAuthClientSecret: keyVaultCommon.getSecret('store-admin-auth-client-secret') 203 | storeAdminAuthTenantId: keyVaultCommon.getSecret('store-admin-auth-tenant-id') 204 | tags: tags 205 | } 206 | } 207 | 208 | @description('URL for accessing store application') 209 | output storeUrl string = public_apps.outputs.storeFrontUri 210 | 211 | @description('URL for accessing store admin application') 212 | output storeAdminUrl string = public_apps.outputs.storeAdminUri 213 | -------------------------------------------------------------------------------- /aks-store-on-aca/modules/aca-common.bicep: -------------------------------------------------------------------------------- 1 | param location string 2 | param logAnalyticsCustomerId string 3 | param managedIdentityId string 4 | param nsgName string 5 | param subnetId string 6 | param tags object 7 | 8 | @secure() 9 | param logAnalyticsKey string 10 | 11 | resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2023-11-02-preview' = { 12 | name: 'cae-aca-store' 13 | location: location 14 | identity: { 15 | type: 'UserAssigned' 16 | userAssignedIdentities: { 17 | '${managedIdentityId}' : {} 18 | } 19 | } 20 | properties: { 21 | appLogsConfiguration: { 22 | destination: 'log-analytics' 23 | logAnalyticsConfiguration: { 24 | customerId: logAnalyticsCustomerId 25 | sharedKey: logAnalyticsKey 26 | } 27 | } 28 | vnetConfiguration: { 29 | infrastructureSubnetId: subnetId 30 | } 31 | zoneRedundant: true 32 | } 33 | tags: tags 34 | } 35 | 36 | resource containerAppsInboundNsgRule 'Microsoft.Network/networkSecurityGroups/securityRules@2023-05-01' = { 37 | name: '${nsgName}/AllowInternet443FrontendInbound' 38 | properties: { 39 | protocol: 'TCP' 40 | sourcePortRange: '*' 41 | destinationPortRange: '443' 42 | sourceAddressPrefix: 'Internet' 43 | destinationAddressPrefix: containerAppsEnvironment.properties.staticIp 44 | access: 'Allow' 45 | priority: 100 46 | direction: 'Inbound' 47 | } 48 | } 49 | 50 | output environmentId string = containerAppsEnvironment.id 51 | -------------------------------------------------------------------------------- /aks-store-on-aca/modules/aca-internal-apps.bicep: -------------------------------------------------------------------------------- 1 | param environmentId string 2 | param location string 3 | param managedIdentityId string 4 | param openAIDeploymentName string 5 | param openAIEndpointSecretUri string 6 | param openAIKeySecretUri string 7 | param subnetIpRange string 8 | param tags object 9 | 10 | @secure() 11 | param queueUsername string 12 | 13 | @secure() 14 | param queuePass string 15 | 16 | /* ConfigMap isn't supported in Azure Container Apps, but an alternative way is to mount a file containing the needed information to the RabbitMQ container app. */ 17 | var rabbitmqPluginsConf = loadTextContent('rabbitmq_enabled_plugins') 18 | 19 | resource mongodb 'Microsoft.App/containerApps@2023-05-02-preview' = { 20 | name: 'mongodb' 21 | location: location 22 | identity: { 23 | type: 'UserAssigned' 24 | userAssignedIdentities: { 25 | '${managedIdentityId}' : {} 26 | } 27 | } 28 | properties: { 29 | managedEnvironmentId: environmentId 30 | configuration: { 31 | ingress: { 32 | external: false 33 | targetPort: 27017 34 | transport: 'tcp' 35 | ipSecurityRestrictions: [ 36 | { 37 | name: 'AllowSnet' 38 | description: 'Allow access from main subnet' 39 | action: 'Allow' 40 | ipAddressRange: subnetIpRange 41 | } 42 | ] 43 | } 44 | } 45 | template: { 46 | containers: [ 47 | { 48 | image: 'mcr.microsoft.com/mirror/docker/library/mongo:4.2' 49 | name: 'mongodb' 50 | resources: { 51 | cpu: json('0.5') 52 | memory: '1.0Gi' 53 | } 54 | probes: [ 55 | { 56 | type: 'liveness' 57 | tcpSocket: { 58 | port: 27017 59 | } 60 | initialDelaySeconds: 5 61 | periodSeconds: 5 62 | } 63 | ] 64 | } 65 | ] 66 | scale: { 67 | minReplicas: 1 68 | maxReplicas: 3 69 | } 70 | } 71 | } 72 | tags: tags 73 | } 74 | 75 | resource rabbitmq 'Microsoft.App/containerApps@2023-05-02-preview' = { 76 | name: 'rabbitmq' 77 | location: location 78 | identity: { 79 | type: 'UserAssigned' 80 | userAssignedIdentities: { 81 | '${managedIdentityId}' : {} 82 | } 83 | } 84 | properties: { 85 | managedEnvironmentId: environmentId 86 | configuration: { 87 | ingress: { 88 | external: false 89 | targetPort: 5672 90 | transport: 'tcp' 91 | additionalPortMappings: [ 92 | { 93 | external: false 94 | targetPort: 15672 95 | } 96 | ] 97 | ipSecurityRestrictions: [ 98 | { 99 | name: 'AllowSnet' 100 | description: 'Allow access from main subnet' 101 | action: 'Allow' 102 | ipAddressRange: subnetIpRange 103 | } 104 | ] 105 | } 106 | secrets: [ 107 | { 108 | name: 'rabbitmq-enabled-plugins' 109 | value: rabbitmqPluginsConf 110 | } 111 | ] 112 | } 113 | template: { 114 | containers: [ 115 | { 116 | image: 'mcr.microsoft.com/mirror/docker/library/rabbitmq:3.10-management-alpine' 117 | name: 'rabbitmq' 118 | resources: { 119 | cpu: json('0.5') 120 | memory: '1.0Gi' 121 | } 122 | env: [ 123 | { 124 | name: 'RABBITMQ_DEFAULT_USER' 125 | value: queueUsername 126 | } 127 | { 128 | name: 'RABBITMQ_DEFAULT_PASS' 129 | value: queuePass 130 | } 131 | ] 132 | volumeMounts: [ 133 | { 134 | volumeName: 'rabbitmq-enabled-plugins' 135 | mountPath: '/etc/rabbitmq/enabled_plugins' 136 | subPath: 'enabled_plugins' 137 | } 138 | ] 139 | } 140 | ] 141 | scale: { 142 | minReplicas: 1 143 | maxReplicas: 3 144 | } 145 | volumes: [ 146 | { 147 | name: 'rabbitmq-enabled-plugins' 148 | storageType: 'Secret' 149 | secrets: [ 150 | { 151 | secretRef: 'rabbitmq-enabled-plugins' 152 | path: 'enabled_plugins' 153 | } 154 | ] 155 | } 156 | ] 157 | } 158 | } 159 | tags: tags 160 | } 161 | 162 | resource orderservice 'Microsoft.App/containerApps@2023-05-02-preview' = { 163 | name: 'order-service' 164 | location: location 165 | identity: { 166 | type: 'UserAssigned' 167 | userAssignedIdentities: { 168 | '${managedIdentityId}' : {} 169 | } 170 | } 171 | properties: { 172 | managedEnvironmentId: environmentId 173 | configuration: { 174 | ingress: { 175 | external: false 176 | targetPort: 3000 177 | transport: 'http' 178 | allowInsecure: true // required for this service due to limitations in the original application 179 | ipSecurityRestrictions: [ 180 | { 181 | name: 'AllowSnet' 182 | description: 'Allow access from main subnet' 183 | action: 'Allow' 184 | ipAddressRange: subnetIpRange 185 | } 186 | ] 187 | } 188 | } 189 | template: { 190 | containers: [ 191 | { 192 | image: 'ghcr.io/azure-samples/aks-store-demo/order-service:latest' 193 | name: 'order-service' 194 | resources: { 195 | cpu: json('0.25') 196 | memory: '0.5Gi' 197 | } 198 | env: [ 199 | { 200 | name: 'ORDER_QUEUE_HOSTNAME' 201 | value: 'rabbitmq' 202 | } 203 | { 204 | name: 'ORDER_QUEUE_PORT' 205 | value: '5672' 206 | } 207 | { 208 | name: 'ORDER_QUEUE_USERNAME' 209 | value: queueUsername 210 | } 211 | { 212 | name: 'ORDER_QUEUE_PASSWORD' 213 | value: queuePass 214 | } 215 | { 216 | name: 'ORDER_QUEUE_NAME' 217 | value: 'orders' 218 | } 219 | { 220 | name: 'FASTIFY_ADDRESS' 221 | value: '0.0.0.0' 222 | } 223 | ] 224 | probes: [ 225 | { 226 | type: 'Liveness' 227 | httpGet: { 228 | path: '/health' 229 | port: 3000 230 | } 231 | initialDelaySeconds: 3 232 | periodSeconds: 5 233 | failureThreshold: 5 234 | } 235 | { 236 | type: 'Readiness' 237 | httpGet: { 238 | path: '/health' 239 | port: 3000 240 | } 241 | initialDelaySeconds: 3 242 | periodSeconds: 5 243 | failureThreshold: 3 244 | } 245 | { 246 | type: 'Startup' 247 | httpGet: { 248 | path: '/health' 249 | port: 3000 250 | } 251 | initialDelaySeconds: 15 252 | periodSeconds: 5 253 | failureThreshold: 3 254 | } 255 | ] 256 | } 257 | ] 258 | //initContainers: [ 259 | // { 260 | // name: 'wait-for-rabbitmq' 261 | // image: 'busybox' 262 | // command: [ 263 | // 'sh' 264 | // '-c' 265 | // 'until nc -zv rabbitmq 5672; do echo "waiting for rabbitmq"; sleep 2; done;' 266 | // ] 267 | // resources: { 268 | // cpu: json('0.25') 269 | // memory: '0.5Gi' 270 | // } 271 | // } 272 | //] 273 | scale: { 274 | minReplicas: 1 275 | maxReplicas: 3 276 | } 277 | } 278 | } 279 | tags: tags 280 | } 281 | 282 | resource makelineservice 'Microsoft.App/containerApps@2023-05-02-preview' = { 283 | name: 'makeline-service' 284 | location: location 285 | identity: { 286 | type: 'UserAssigned' 287 | userAssignedIdentities: { 288 | '${managedIdentityId}' : {} 289 | } 290 | } 291 | properties: { 292 | managedEnvironmentId: environmentId 293 | configuration: { 294 | ingress: { 295 | external: false 296 | targetPort: 3001 297 | transport: 'http' 298 | allowInsecure: true // required for this service due to limitations in the original application 299 | ipSecurityRestrictions: [ 300 | { 301 | name: 'AllowSnet' 302 | description: 'Allow access from main subnet' 303 | action: 'Allow' 304 | ipAddressRange: subnetIpRange 305 | } 306 | ] 307 | } 308 | } 309 | template: { 310 | containers: [ 311 | { 312 | image: 'ghcr.io/azure-samples/aks-store-demo/makeline-service:latest' 313 | name: 'makeline-service' 314 | resources: { 315 | cpu: json('0.25') 316 | memory: '0.5Gi' 317 | } 318 | env: [ 319 | { 320 | name: 'ORDER_QUEUE_URI' 321 | value: 'amqp://rabbitmq:5672' 322 | } 323 | { 324 | name: 'ORDER_QUEUE_USERNAME' 325 | value: queueUsername 326 | } 327 | { 328 | name: 'ORDER_QUEUE_PASSWORD' 329 | value: queuePass 330 | } 331 | { 332 | name: 'ORDER_QUEUE_NAME' 333 | value: 'orders' 334 | } 335 | { 336 | name: 'ORDER_DB_URI' 337 | value: 'mongodb://mongodb:27017' 338 | } 339 | { 340 | name: 'ORDER_DB_NAME' 341 | value: 'orderdb' 342 | } 343 | { 344 | name: 'ORDER_DB_COLLECTION_NAME' 345 | value: 'orders' 346 | } 347 | ] 348 | probes: [ 349 | { 350 | type: 'Liveness' 351 | httpGet: { 352 | path: '/health' 353 | port: 3001 354 | } 355 | initialDelaySeconds: 3 356 | periodSeconds: 3 357 | failureThreshold: 5 358 | } 359 | { 360 | type: 'Readiness' 361 | httpGet: { 362 | path: '/health' 363 | port: 3001 364 | } 365 | initialDelaySeconds: 3 366 | periodSeconds: 5 367 | failureThreshold: 3 368 | } 369 | ] 370 | } 371 | ] 372 | scale: { 373 | minReplicas: 1 374 | maxReplicas: 3 375 | } 376 | } 377 | } 378 | tags: tags 379 | } 380 | 381 | resource productservice 'Microsoft.App/containerApps@2023-05-02-preview' = { 382 | name: 'product-service' 383 | location: location 384 | identity: { 385 | type: 'UserAssigned' 386 | userAssignedIdentities: { 387 | '${managedIdentityId}' : {} 388 | } 389 | } 390 | properties: { 391 | managedEnvironmentId: environmentId 392 | configuration: { 393 | ingress: { 394 | external: false 395 | targetPort: 3002 396 | transport: 'http' 397 | allowInsecure: false 398 | clientCertificateMode: 'accept' 399 | ipSecurityRestrictions: [ 400 | { 401 | name: 'AllowSnet' 402 | description: 'Allow access from main subnet' 403 | action: 'Allow' 404 | ipAddressRange: subnetIpRange 405 | } 406 | ] 407 | } 408 | } 409 | template: { 410 | containers: [ 411 | { 412 | image: 'ghcr.io/azure-samples/aks-store-demo/product-service:latest' 413 | name: 'product-service' 414 | resources: { 415 | cpu: json('0.25') 416 | memory: '0.5Gi' 417 | } 418 | env: [ 419 | { 420 | name: 'AI_SERVICE_URL' 421 | value: 'https://${aiservice.properties.configuration.ingress.fqdn}' 422 | } 423 | ] 424 | probes: [ 425 | { 426 | type: 'Liveness' 427 | httpGet: { 428 | path: '/health' 429 | port: 3002 430 | } 431 | initialDelaySeconds: 3 432 | periodSeconds: 3 433 | failureThreshold: 5 434 | } 435 | { 436 | type: 'Readiness' 437 | httpGet: { 438 | path: '/health' 439 | port: 3002 440 | } 441 | initialDelaySeconds: 3 442 | periodSeconds: 5 443 | failureThreshold: 3 444 | } 445 | ] 446 | 447 | } 448 | ] 449 | scale: { 450 | minReplicas: 1 451 | maxReplicas: 3 452 | } 453 | } 454 | } 455 | tags: tags 456 | } 457 | 458 | resource aiservice 'Microsoft.App/containerApps@2023-05-02-preview' = { 459 | name: 'ai-service' 460 | location: location 461 | identity: { 462 | type: 'UserAssigned' 463 | userAssignedIdentities: { 464 | '${managedIdentityId}' : {} 465 | } 466 | } 467 | properties: { 468 | managedEnvironmentId: environmentId 469 | configuration: { 470 | ingress: { 471 | external: false 472 | targetPort: 5001 473 | transport: 'http' 474 | allowInsecure: false 475 | clientCertificateMode: 'accept' 476 | ipSecurityRestrictions: [ 477 | { 478 | name: 'AllowSnet' 479 | description: 'Allow access from main subnet' 480 | action: 'Allow' 481 | ipAddressRange: subnetIpRange 482 | } 483 | ] 484 | } 485 | secrets: [ 486 | { 487 | name: 'openai-key-uri' 488 | keyVaultUrl: openAIKeySecretUri 489 | identity: managedIdentityId 490 | } 491 | { 492 | name: 'openai-endpoint-uri' 493 | keyVaultUrl: openAIEndpointSecretUri 494 | identity: managedIdentityId 495 | } 496 | ] 497 | } 498 | template: { 499 | containers: [ 500 | { 501 | image: 'ghcr.io/azure-samples/aks-store-demo/ai-service:latest' 502 | name: 'product-service' 503 | resources: { 504 | cpu: json('0.25') 505 | memory: '0.5Gi' 506 | } 507 | env: [ 508 | { 509 | name: 'USE_AZURE_OPENAI' 510 | value: 'true' 511 | } 512 | { 513 | name: 'AZURE_OPENAI_DEPLOYMENT_NAME' 514 | value: openAIDeploymentName 515 | } 516 | { 517 | name: 'AZURE_OPENAI_ENDPOINT' 518 | secretRef: 'openai-endpoint-uri' 519 | } 520 | { 521 | name: 'OPENAI_API_KEY' 522 | secretRef: 'openai-key-uri' 523 | } 524 | ] 525 | probes: [ 526 | { 527 | type: 'Liveness' 528 | httpGet: { 529 | path: '/health' 530 | port: 5001 531 | } 532 | initialDelaySeconds: 3 533 | periodSeconds: 3 534 | failureThreshold: 5 535 | } 536 | { 537 | type: 'Readiness' 538 | httpGet: { 539 | path: '/health' 540 | port: 5001 541 | } 542 | initialDelaySeconds: 3 543 | periodSeconds: 5 544 | failureThreshold: 3 545 | } 546 | ] 547 | 548 | } 549 | ] 550 | scale: { 551 | minReplicas: 1 552 | maxReplicas: 3 553 | } 554 | } 555 | } 556 | tags: tags 557 | } 558 | 559 | resource virtualcustomer 'Microsoft.App/containerApps@2023-05-02-preview' = { 560 | name: 'virtual-customer' 561 | location: location 562 | identity: { 563 | type: 'UserAssigned' 564 | userAssignedIdentities: { 565 | '${managedIdentityId}' : {} 566 | } 567 | } 568 | properties: { 569 | managedEnvironmentId: environmentId 570 | template: { 571 | containers: [ 572 | { 573 | image: 'ghcr.io/azure-samples/aks-store-demo/virtual-customer:latest' 574 | name: 'virtual-customer' 575 | resources: { 576 | cpu: json('0.25') 577 | memory: '0.5Gi' 578 | } 579 | env: [ 580 | { 581 | name: 'ORDER_SERVICE_URL' 582 | value: 'http://${orderservice.properties.configuration.ingress.fqdn}' 583 | } 584 | { 585 | name: 'ORDERS_PER_HOUR' 586 | value: '100' 587 | } 588 | ] 589 | } 590 | ] 591 | scale: { 592 | minReplicas: 1 593 | maxReplicas: 3 594 | } 595 | } 596 | } 597 | tags: tags 598 | } 599 | 600 | resource virtualworker 'Microsoft.App/containerApps@2023-05-02-preview' = { 601 | name: 'virtual-worker' 602 | location: location 603 | identity: { 604 | type: 'UserAssigned' 605 | userAssignedIdentities: { 606 | '${managedIdentityId}' : {} 607 | } 608 | } 609 | properties: { 610 | managedEnvironmentId: environmentId 611 | template: { 612 | containers: [ 613 | { 614 | image: 'ghcr.io/azure-samples/aks-store-demo/virtual-worker:latest' 615 | name: 'virtual-worker' 616 | resources: { 617 | cpu: json('0.25') 618 | memory: '0.5Gi' 619 | } 620 | env: [ 621 | { 622 | name: 'MAKELINE_SERVICE_URL' 623 | value: 'http://${makelineservice.properties.configuration.ingress.fqdn}' 624 | } 625 | { 626 | name: 'ORDERS_PER_HOUR' 627 | value: '100' 628 | } 629 | ] 630 | } 631 | ] 632 | scale: { 633 | minReplicas: 1 634 | maxReplicas: 3 635 | } 636 | } 637 | } 638 | tags: tags 639 | } 640 | 641 | output makelineServiceUri string = 'https://${makelineservice.properties.configuration.ingress.fqdn}' 642 | output orderServiceUri string = 'https://${orderservice.properties.configuration.ingress.fqdn}' 643 | output productServiceUri string = 'https://${productservice.properties.configuration.ingress.fqdn}' 644 | -------------------------------------------------------------------------------- /aks-store-on-aca/modules/aca-public-apps.bicep: -------------------------------------------------------------------------------- 1 | import { replaceMultipleStrings } from '../functions.bicep' 2 | 3 | param environmentId string 4 | param location string 5 | param makelineServiceUri string 6 | param managedIdentityId string 7 | param orderServiceUri string 8 | param productServiceUri string 9 | param tags object 10 | 11 | @secure() 12 | param storeAdminAuthClientId string 13 | 14 | @secure() 15 | param storeAdminAuthClientSecret string 16 | 17 | @secure() 18 | param storeAdminAuthTenantId string 19 | 20 | /* Due to hard-coded URLs and port numbers in the NGINX configuration in the original source code, instead of opening up additional unused ports in Azure Container Apps to support this 21 | * NGINX configuration is overriden in a way that would work more natively for Azure Container Apps. NGINX configuration files for store-front and store-admin apps are stored in .conf files in the current folder. 22 | */ 23 | var storeFrontNginxConfReplacements = { 24 | '{ORDER_SERVICE_URI}': orderServiceUri 25 | '{PRODUCT_SERVICE_URI}': productServiceUri 26 | } 27 | 28 | var storeAdminNginxConfReplacements = { 29 | '{MAKELINE_SERVICE_URI}': makelineServiceUri 30 | '{ORDER_SERVICE_URI}': orderServiceUri 31 | '{PRODUCT_SERVICE_URI}': productServiceUri 32 | } 33 | 34 | var storeFrontNginxConf = replaceMultipleStrings(loadTextContent('storeFrontNginx.conf'), storeFrontNginxConfReplacements) 35 | var storeAdminNginxConf = replaceMultipleStrings(loadTextContent('storeAdminNginx.conf'), storeAdminNginxConfReplacements) 36 | 37 | resource storefront 'Microsoft.App/containerApps@2023-05-02-preview' = { 38 | name: 'store-front' 39 | location: location 40 | identity: { 41 | type: 'UserAssigned' 42 | userAssignedIdentities: { 43 | '${managedIdentityId}' : {} 44 | } 45 | } 46 | properties: { 47 | managedEnvironmentId: environmentId 48 | configuration: { 49 | ingress: { 50 | external: true 51 | targetPort: 8080 52 | transport: 'http' 53 | clientCertificateMode: 'accept' 54 | } 55 | secrets: [ 56 | { 57 | name: 'nginx-conf' 58 | value: storeFrontNginxConf 59 | } 60 | ] 61 | } 62 | template: { 63 | containers: [ 64 | { 65 | image: 'ghcr.io/azure-samples/aks-store-demo/store-front:latest' 66 | name: 'store-front' 67 | resources: { 68 | cpu: json('1.0') 69 | memory: '2.0Gi' 70 | } 71 | env: [ 72 | { 73 | name: 'VUE_APP_ORDER_SERVICE_URL' 74 | value: orderServiceUri 75 | } 76 | { 77 | name: 'VUE_APP_PRODUCT_SERVICE_URL' 78 | value: productServiceUri 79 | } 80 | ] 81 | command: [ 82 | '/bin/sh' 83 | '-c' 84 | 'echo Ready to serve! && nginx -g \'daemon off;\'' 85 | ] 86 | volumeMounts: [ 87 | { 88 | mountPath: '/etc/nginx/conf.d/' 89 | volumeName: 'nginx-conf' 90 | } 91 | ] 92 | probes: [ 93 | { 94 | type: 'Liveness' 95 | httpGet: { 96 | path: '/health' 97 | port: 8080 98 | } 99 | initialDelaySeconds: 3 100 | periodSeconds: 3 101 | failureThreshold: 5 102 | } 103 | { 104 | type: 'Readiness' 105 | httpGet: { 106 | path: '/health' 107 | port: 8080 108 | } 109 | initialDelaySeconds: 3 110 | periodSeconds: 3 111 | failureThreshold: 3 112 | } 113 | { 114 | type: 'Startup' 115 | httpGet: { 116 | path: '/health' 117 | port: 8080 118 | } 119 | initialDelaySeconds: 5 120 | periodSeconds: 5 121 | failureThreshold: 3 122 | } 123 | ] 124 | } 125 | ] 126 | scale: { 127 | minReplicas: 1 128 | maxReplicas: 3 129 | } 130 | volumes: [ 131 | { 132 | name: 'nginx-conf' 133 | storageType: 'Secret' 134 | secrets: [ 135 | { 136 | secretRef: 'nginx-conf' 137 | path: 'default.conf' 138 | } 139 | ] 140 | } 141 | ] 142 | } 143 | } 144 | tags: tags 145 | } 146 | 147 | resource storeadmin 'Microsoft.App/containerApps@2023-05-02-preview' = { 148 | name: 'store-admin' 149 | location: location 150 | identity: { 151 | type: 'UserAssigned' 152 | userAssignedIdentities: { 153 | '${managedIdentityId}' : {} 154 | } 155 | } 156 | properties: { 157 | managedEnvironmentId: environmentId 158 | configuration: { 159 | ingress: { 160 | external: true 161 | targetPort: 8081 162 | transport: 'http' 163 | clientCertificateMode: 'accept' 164 | } 165 | secrets: [ 166 | { 167 | name: 'nginx-conf' 168 | value: storeAdminNginxConf 169 | } 170 | { 171 | name: 'microsoft-provider-authentication-secret' 172 | value: storeAdminAuthClientSecret 173 | } 174 | ] 175 | } 176 | template: { 177 | containers: [ 178 | { 179 | image: 'ghcr.io/azure-samples/aks-store-demo/store-admin:latest' 180 | 181 | name: 'store-admin' 182 | resources: { 183 | cpu: json('1.0') 184 | memory: '2.0Gi' 185 | } 186 | command: [ 187 | '/bin/sh' 188 | '-c' 189 | 'echo Ready to serve! && nginx -g \'daemon off;\'' 190 | ] 191 | env: [ 192 | { 193 | name: 'VUE_APP_MAKELINE_SERVICE_URL' 194 | value: makelineServiceUri 195 | } 196 | { 197 | name: 'VUE_APP_PRODUCT_SERVICE_URL' 198 | value: productServiceUri 199 | } 200 | ] 201 | volumeMounts: [ 202 | { 203 | mountPath: '/etc/nginx/conf.d/' 204 | volumeName: 'nginx-conf' 205 | } 206 | ] 207 | probes: [ 208 | { 209 | type: 'Liveness' 210 | httpGet: { 211 | path: '/health' 212 | port: 8081 213 | } 214 | initialDelaySeconds: 3 215 | periodSeconds: 3 216 | failureThreshold: 5 217 | } 218 | { 219 | type: 'Readiness' 220 | httpGet: { 221 | path: '/health' 222 | port: 8081 223 | } 224 | initialDelaySeconds: 3 225 | periodSeconds: 5 226 | failureThreshold: 3 227 | } 228 | { 229 | type: 'Startup' 230 | httpGet: { 231 | path: '/health' 232 | port: 8081 233 | } 234 | initialDelaySeconds: 5 235 | periodSeconds: 5 236 | failureThreshold: 3 237 | } 238 | ] 239 | } 240 | ] 241 | scale: { 242 | minReplicas: 1 243 | maxReplicas: 3 244 | } 245 | volumes: [ 246 | { 247 | name: 'nginx-conf' 248 | storageType: 'Secret' 249 | secrets: [ 250 | { 251 | secretRef: 'nginx-conf' 252 | path: 'default.conf' 253 | } 254 | ] 255 | } 256 | ] 257 | } 258 | } 259 | tags: tags 260 | } 261 | 262 | @description('This resource enables authentication for the Store Admin application using Microsoft Entra ID as the identity provider and information about existing application registration.') 263 | resource storeAdminAuthConfig 'Microsoft.App/containerApps/authConfigs@2023-11-02-preview' = { 264 | name: 'current' // required name 265 | parent: storeadmin 266 | properties: { 267 | globalValidation: { 268 | redirectToProvider: 'azureactivedirectory' 269 | unauthenticatedClientAction: 'RedirectToLoginPage' 270 | } 271 | httpSettings: { 272 | requireHttps: true 273 | } 274 | identityProviders: { 275 | azureActiveDirectory: { 276 | enabled: true 277 | registration: { 278 | clientId: storeAdminAuthClientId 279 | clientSecretSettingName: 'microsoft-provider-authentication-secret' 280 | openIdIssuer: 'https://sts.windows.net/${storeAdminAuthTenantId}/v2.0' 281 | } 282 | validation: { 283 | allowedAudiences: [ 284 | 'api://${storeAdminAuthClientId}' 285 | ] 286 | } 287 | } 288 | } 289 | platform: { 290 | enabled: true 291 | } 292 | } 293 | } 294 | 295 | output storeFrontUri string = 'https://${storefront.properties.configuration.ingress.fqdn}' 296 | output storeAdminUri string = 'https://${storeadmin.properties.configuration.ingress.fqdn}' 297 | -------------------------------------------------------------------------------- /aks-store-on-aca/modules/ai.bicep: -------------------------------------------------------------------------------- 1 | param openAIDnsZoneName string 2 | param keyVaultName string 3 | param location string 4 | param managedIdentityId string 5 | param openAILocation string 6 | param subnetId string 7 | param tags object 8 | 9 | var cognitiveAccountName = 'coga-${uniqueString('cognitive', resourceGroup().id)}' 10 | 11 | resource keyVaultACA 'Microsoft.KeyVault/vaults@2022-07-01' existing = { 12 | name: keyVaultName 13 | } 14 | 15 | resource openAIDnsZone 'Microsoft.Network/privateDnsZones@2020-06-01' existing = { 16 | name: openAIDnsZoneName 17 | } 18 | 19 | resource cognitiveAccount 'Microsoft.CognitiveServices/accounts@2023-05-01' = { 20 | name: cognitiveAccountName 21 | location: openAILocation 22 | sku: { 23 | name: 'S0' 24 | } 25 | kind: 'OpenAI' 26 | identity: { 27 | type: 'UserAssigned' 28 | userAssignedIdentities: { 29 | '${managedIdentityId}' : {} 30 | } 31 | } 32 | properties: { 33 | customSubDomainName: cognitiveAccountName 34 | publicNetworkAccess: 'Disabled' 35 | restrictOutboundNetworkAccess: false 36 | disableLocalAuth: false 37 | } 38 | tags: tags 39 | } 40 | 41 | resource cognitiveAccountDeploymentGpt35Turbo 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = { 42 | parent: cognitiveAccount 43 | name: 'gpt-35-turbo' 44 | sku: { 45 | name: 'Standard' 46 | capacity: 240 47 | } 48 | properties: { 49 | model: { 50 | format: 'OpenAI' 51 | name: 'gpt-35-turbo' 52 | version: '0301' 53 | } 54 | } 55 | } 56 | 57 | resource privateEndpointCognitiveAccount 'Microsoft.Network/privateEndpoints@2023-04-01' = { 58 | name: 'pe-${cognitiveAccountName}' 59 | location: location 60 | properties: { 61 | customNetworkInterfaceName: '${cognitiveAccountName}-nic-deluxe' 62 | privateLinkServiceConnections: [ 63 | { 64 | name: 'psc-${cognitiveAccountName}' 65 | properties: { 66 | privateLinkServiceId: cognitiveAccount.id 67 | groupIds: [ 68 | 'account' 69 | ] 70 | } 71 | } 72 | ] 73 | subnet: { 74 | id: subnetId 75 | } 76 | } 77 | tags: tags 78 | } 79 | 80 | resource cogaPrivateDnsZoneGroup 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2023-04-01' = { 81 | name: '${privateEndpointCognitiveAccount.name}-dns-zone-group' 82 | parent: privateEndpointCognitiveAccount 83 | properties: { 84 | privateDnsZoneConfigs: [ 85 | { 86 | name: 'config1' 87 | properties: { 88 | privateDnsZoneId: openAIDnsZone.id 89 | } 90 | } 91 | ] 92 | } 93 | } 94 | 95 | resource openAIKeySecret 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = { 96 | parent: keyVaultACA 97 | name: 'cogaKey' 98 | properties: { 99 | value: cognitiveAccount.listKeys().key1 100 | } 101 | } 102 | 103 | resource cognitiveAccountEndpoint 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = { 104 | parent: keyVaultACA 105 | name: 'cogaEndpoint' 106 | properties: { 107 | value: cognitiveAccount.properties.endpoint 108 | } 109 | } 110 | 111 | output openAIDeploymentName string = cognitiveAccountDeploymentGpt35Turbo.name 112 | output openAIKeySecretUri string = openAIKeySecret.properties.secretUri 113 | output openAIEndpointSecretUri string = cognitiveAccountEndpoint.properties.secretUri 114 | -------------------------------------------------------------------------------- /aks-store-on-aca/modules/azure-monitor.bicep: -------------------------------------------------------------------------------- 1 | param amplsPrivateDnsZones array 2 | param environment string 3 | param keyVaultName string 4 | param location string 5 | param locationPrefix string 6 | param managedIdentityId string 7 | param subnetId string 8 | param tags object 9 | 10 | 11 | var privateDnsZoneConfigs = [ for zone in amplsPrivateDnsZones : { 12 | name: replace(zone, '.', '-') 13 | properties: { 14 | privateDnsZoneId: resourceId('Microsoft.Network/privateDnsZones', zone) 15 | } 16 | }] 17 | 18 | resource keyVaultACA 'Microsoft.KeyVault/vaults@2022-07-01' existing = { 19 | name: keyVaultName 20 | } 21 | 22 | resource ampls 'microsoft.insights/privateLinkScopes@2021-07-01-preview' = { 23 | name: 'ampls-${locationPrefix}-${environment}' 24 | location: 'global' 25 | tags: tags 26 | properties: { 27 | accessModeSettings: { 28 | ingestionAccessMode: 'PrivateOnly' 29 | queryAccessMode: 'Open' 30 | } 31 | } 32 | } 33 | 34 | resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2022-10-01' = { 35 | name: 'log-aca-${environment}' 36 | location: location 37 | identity: { 38 | type: 'UserAssigned' 39 | userAssignedIdentities: { 40 | '${managedIdentityId}' : {} 41 | } 42 | } 43 | properties: { 44 | retentionInDays: 30 45 | sku: { 46 | name: 'PerGB2018' 47 | } 48 | publicNetworkAccessForIngestion: 'Disabled' 49 | publicNetworkAccessForQuery: 'Enabled' 50 | } 51 | tags: tags 52 | } 53 | 54 | resource logAnalyticsAMPLSConnection 'Microsoft.Insights/privateLinkScopes/scopedResources@2021-07-01-preview' = { 55 | name: 'ampls-${logAnalytics.name}' 56 | parent: ampls 57 | properties: { 58 | linkedResourceId: logAnalytics.id 59 | } 60 | } 61 | 62 | resource privateEndpointAMPLS 'Microsoft.Network/privateEndpoints@2023-04-01' = { 63 | name: 'pe-${ampls.name}' 64 | location: location 65 | properties: { 66 | customNetworkInterfaceName: '${ampls.name}-nic-deluxe' 67 | privateLinkServiceConnections: [ 68 | { 69 | name: 'psc-${ampls.name}' 70 | properties: { 71 | privateLinkServiceId: ampls.id 72 | groupIds: [ 73 | 'azuremonitor' 74 | ] 75 | } 76 | } 77 | ] 78 | subnet: { 79 | id: subnetId 80 | } 81 | } 82 | dependsOn: [logAnalyticsAMPLSConnection] 83 | tags: tags 84 | } 85 | 86 | resource amplsPrivateDnsZoneGroup 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2023-04-01' = { 87 | name: 'default' 88 | parent: privateEndpointAMPLS 89 | properties: { 90 | privateDnsZoneConfigs: privateDnsZoneConfigs 91 | } 92 | } 93 | 94 | resource logAnalyticsKeySecret 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = { 95 | parent: keyVaultACA 96 | name: '${logAnalytics.name}-key' 97 | properties: { 98 | attributes: { 99 | enabled: true 100 | } 101 | value: logAnalytics.listKeys().primarySharedKey 102 | } 103 | tags: tags 104 | } 105 | 106 | resource kvDiagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = { 107 | name: keyVaultName 108 | scope: keyVaultACA 109 | properties: { 110 | workspaceId: logAnalytics.id 111 | logs: [ 112 | { 113 | categoryGroup: 'audit' 114 | enabled: true 115 | } 116 | ] 117 | } 118 | } 119 | 120 | output logAnalyticsWorkspaceId string = logAnalytics.id 121 | output logAnalyticsCustomerId string = logAnalytics.properties.customerId 122 | output logAnalyticsKey string = logAnalyticsKeySecret.name 123 | -------------------------------------------------------------------------------- /aks-store-on-aca/modules/common.bicep: -------------------------------------------------------------------------------- 1 | param environment string 2 | param location string 3 | param tags object 4 | 5 | resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { 6 | name: 'uaid-aca-common-${environment}' 7 | location: location 8 | tags: tags 9 | } 10 | 11 | output managedIdentityId string = managedIdentity.id 12 | output managedIdentityName string = managedIdentity.name 13 | -------------------------------------------------------------------------------- /aks-store-on-aca/modules/dns.bicep: -------------------------------------------------------------------------------- 1 | param privateDnsZones array 2 | param tags object 3 | 4 | resource dnsZones 'Microsoft.Network/privateDnsZones@2020-06-01' = [for zone in privateDnsZones : { 5 | name: zone 6 | location: 'global' 7 | properties: {} 8 | tags: tags 9 | }] 10 | -------------------------------------------------------------------------------- /aks-store-on-aca/modules/keyvault.bicep: -------------------------------------------------------------------------------- 1 | param keyVaultDnsZoneName string 2 | param location string 3 | param managedIdentityName string 4 | param subnetId string 5 | param tags object 6 | 7 | var tenantId = subscription().tenantId 8 | 9 | resource keyVaultSecretsOfficerRoleDefinition 'Microsoft.Authorization/roleDefinitions@2018-01-01-preview' existing = { 10 | scope: subscription() 11 | name: 'b86a8fe4-44ce-4948-aee5-eccb2c155cd7' 12 | } 13 | 14 | resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' existing = { 15 | name: managedIdentityName 16 | } 17 | 18 | resource keyVaultDnsZone 'Microsoft.Network/privateDnsZones@2020-06-01' existing = { 19 | name: keyVaultDnsZoneName 20 | } 21 | 22 | resource keyVault 'Microsoft.KeyVault/vaults@2021-10-01' = { 23 | name: 'kv-${uniqueString('keyvault', resourceGroup().id, deployment().name)}' 24 | location: location 25 | properties: { 26 | enabledForTemplateDeployment: true 27 | enableSoftDelete: false // for production you would want it to be enabled, i.e. set to 'true', together with purge protection (enablePurgeProtection: true) 28 | enableRbacAuthorization: true 29 | publicNetworkAccess: 'Disabled' 30 | tenantId: tenantId 31 | networkAcls: { 32 | bypass: 'AzureServices' 33 | defaultAction: 'Deny' 34 | ipRules: [] 35 | virtualNetworkRules: [ 36 | { 37 | id: subnetId 38 | } 39 | ] 40 | } 41 | sku: { 42 | name: 'standard' 43 | family: 'A' 44 | } 45 | } 46 | tags: tags 47 | } 48 | 49 | resource keyVaultroleAssignment 'Microsoft.Authorization/roleAssignments@2020-10-01-preview' = { 50 | name: guid(keyVault.id, managedIdentity.id, keyVaultSecretsOfficerRoleDefinition.id) 51 | scope: keyVault 52 | properties: { 53 | roleDefinitionId: keyVaultSecretsOfficerRoleDefinition.id 54 | principalId: managedIdentity.properties.principalId 55 | principalType: 'ServicePrincipal' 56 | } 57 | } 58 | 59 | resource privateEndpointKeyVault 'Microsoft.Network/privateEndpoints@2023-04-01' = { 60 | name: 'pe-${keyVault.name}' 61 | location: location 62 | properties: { 63 | customNetworkInterfaceName: '${keyVault.name}-nic-deluxe' 64 | privateLinkServiceConnections: [ 65 | { 66 | name: 'psc-${keyVault.name}' 67 | properties: { 68 | privateLinkServiceId: keyVault.id 69 | groupIds: [ 70 | 'vault' 71 | ] 72 | } 73 | } 74 | ] 75 | subnet: { 76 | id: subnetId 77 | } 78 | } 79 | tags: tags 80 | } 81 | 82 | resource keyVaultPrivateDnsZoneGroup 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2023-04-01' = { 83 | name: '${privateEndpointKeyVault.name}-dns-zone-group' 84 | parent: privateEndpointKeyVault 85 | properties: { 86 | privateDnsZoneConfigs: [ 87 | { 88 | name: 'config1' 89 | properties: { 90 | privateDnsZoneId: keyVaultDnsZone.id 91 | } 92 | } 93 | ] 94 | } 95 | } 96 | 97 | output keyVaultId string = keyVault.id 98 | output keyVaultName string = keyVault.name 99 | -------------------------------------------------------------------------------- /aks-store-on-aca/modules/network.bicep: -------------------------------------------------------------------------------- 1 | param environment string 2 | param location string 3 | param locationPrefix string 4 | param subnets array 5 | param tags object 6 | param vnetIpRange string 7 | 8 | var vnetName = 'vnet-${locationPrefix}-${environment}' 9 | 10 | resource vnet 'Microsoft.Network/virtualNetworks@2023-04-01' = { 11 | name: vnetName 12 | location: location 13 | properties: { 14 | addressSpace: { 15 | addressPrefixes: [ 16 | vnetIpRange 17 | ] 18 | } 19 | subnets: [ 20 | for subnet in subnets: { 21 | name: subnet.name 22 | properties: { 23 | addressPrefix: subnet.subnetPrefix 24 | networkSecurityGroup: { 25 | id: nsg.id 26 | } 27 | serviceEndpoints: [ 28 | { 29 | service: 'Microsoft.KeyVault' 30 | locations: [ 31 | location 32 | ] 33 | } 34 | { 35 | service: 'Microsoft.Storage' 36 | locations: [ 37 | location 38 | ] 39 | } 40 | ] 41 | } 42 | } 43 | ] 44 | } 45 | tags: tags 46 | } 47 | 48 | // Network Security Group includes mandatory rules for Azure Container Apps. 49 | // Ref. https://learn.microsoft.com/en-us/azure/container-apps/firewall-integration#nsg-allow-rules 50 | 51 | resource nsg 'Microsoft.Network/networkSecurityGroups@2023-05-01' = { 52 | name: 'nsg-${vnetName}' 53 | location: location 54 | properties: { 55 | securityRules: [ 56 | { 57 | name: 'AllowAny1194UDPAzureCloudOutbound' 58 | properties: { 59 | protocol: 'UDP' 60 | sourcePortRange: '*' 61 | destinationPortRange: '1194' 62 | sourceAddressPrefix: '*' 63 | destinationAddressPrefix: 'AzureCloud.${location}' 64 | access: 'Allow' 65 | priority: 110 66 | direction: 'Outbound' 67 | } 68 | } 69 | { 70 | name: 'AllowAny9000TCPAzureCloudOutbound' 71 | properties: { 72 | protocol: 'TCP' 73 | sourcePortRange: '*' 74 | destinationPortRange: '9000' 75 | sourceAddressPrefix: '*' 76 | destinationAddressPrefix: 'AzureCloud.${location}' 77 | access: 'Allow' 78 | priority: 120 79 | direction: 'Outbound' 80 | } 81 | } 82 | { 83 | name: 'AllowAny443AzureMonitorOutbound' 84 | properties: { 85 | protocol: 'TCP' 86 | sourcePortRange: '*' 87 | destinationPortRange: '443' 88 | sourceAddressPrefix: '*' 89 | destinationAddressPrefix: 'AzureMonitor' 90 | access: 'Allow' 91 | priority: 130 92 | direction: 'Outbound' 93 | } 94 | } 95 | { 96 | name: 'AllowAnyContainerAppsControlPlaneTCPOutbound' 97 | properties: { 98 | protocol: 'TCP' 99 | sourcePortRange: '*' 100 | sourceAddressPrefix: '*' 101 | destinationAddressPrefix: '*' 102 | access: 'Allow' 103 | priority: 140 104 | direction: 'Outbound' 105 | destinationPortRanges: [ 106 | '443' 107 | '5671' 108 | '5672' 109 | ] 110 | } 111 | } 112 | { 113 | name: 'AllowAny123NTPOutbound' 114 | properties: { 115 | protocol: 'UDP' 116 | sourcePortRange: '*' 117 | destinationPortRange: '123' 118 | sourceAddressPrefix: '*' 119 | destinationAddressPrefix: '*' 120 | access: 'Allow' 121 | priority: 150 122 | direction: 'Outbound' 123 | } 124 | } 125 | ] 126 | } 127 | tags: tags 128 | } 129 | 130 | output acaSubnetId string = vnet.properties.subnets[0].id 131 | output acaSubnetIpRange string = vnet.properties.subnets[0].properties.addressPrefix 132 | output nsgName string = nsg.name 133 | output vnetId string = vnet.id 134 | -------------------------------------------------------------------------------- /aks-store-on-aca/modules/rabbitmq_enabled_plugins: -------------------------------------------------------------------------------- 1 | [rabbitmq_management,rabbitmq_prometheus,rabbitmq_amqp1_0]. -------------------------------------------------------------------------------- /aks-store-on-aca/modules/storeAdminNginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 8081; 3 | listen [::]:8081; 4 | server_name localhost; 5 | 6 | #access_log /var/log/nginx/host.access.log main; 7 | 8 | location / { 9 | root /usr/share/nginx/html; 10 | index index.html index.htm; 11 | } 12 | 13 | #error_page 404 /404.html; 14 | 15 | # redirect server error pages to the static page /50x.html 16 | # 17 | error_page 500 502 503 504 /50x.html; 18 | location = /50x.html { 19 | root /usr/share/nginx/html; 20 | } 21 | 22 | location /health { 23 | default_type application/json; 24 | return 200 '{"status":"ok","version":"1.2.0"}'; 25 | } 26 | 27 | location ~ ^/makeline/order/(?\w+) { 28 | proxy_pass {MAKELINE_SERVICE_URI}/order/$id; 29 | proxy_ssl_server_name on; 30 | proxy_http_version 1.1; 31 | } 32 | 33 | location /makeline/order { 34 | proxy_pass {MAKELINE_SERVICE_URI}/order; 35 | proxy_ssl_server_name on; 36 | proxy_http_version 1.1; 37 | } 38 | 39 | location /makeline/order/fetch { 40 | proxy_pass {MAKELINE_SERVICE_URI}/order/fetch; 41 | proxy_ssl_server_name on; 42 | proxy_http_version 1.1; 43 | } 44 | 45 | location /order { 46 | proxy_pass {ORDER_SERVICE_URI}/; 47 | proxy_ssl_server_name on; 48 | proxy_http_version 1.1; 49 | } 50 | 51 | location /products/ { 52 | proxy_pass {PRODUCT_SERVICE_URI}/; 53 | proxy_ssl_server_name on; 54 | proxy_http_version 1.1; 55 | } 56 | 57 | location /products { 58 | proxy_pass {PRODUCT_SERVICE_URI}/; 59 | proxy_ssl_server_name on; 60 | proxy_http_version 1.1; 61 | } 62 | 63 | # location ~* ^/products { 64 | # proxy_pass {PRODUCT_SERVICE_URI}/; 65 | # proxy_ssl_server_name on; 66 | # proxy_http_version 1.1; 67 | # } 68 | 69 | location ~ ^/product/(?\w+) { 70 | proxy_pass {PRODUCT_SERVICE_URI}/$id; 71 | proxy_ssl_server_name on; 72 | proxy_http_version 1.1; 73 | } 74 | 75 | # location ~* ^/product { 76 | # proxy_pass {PRODUCT_SERVICE_URI}/; 77 | # proxy_ssl_server_name on; 78 | # proxy_http_version 1.1; 79 | # } 80 | 81 | location /product { 82 | proxy_pass {PRODUCT_SERVICE_URI}/; 83 | proxy_ssl_server_name on; 84 | proxy_http_version 1.1; 85 | } 86 | 87 | location /product/ { 88 | proxy_pass {PRODUCT_SERVICE_URI}/; 89 | proxy_ssl_server_name on; 90 | proxy_http_version 1.1; 91 | } 92 | 93 | location /ai/health { 94 | proxy_pass {PRODUCT_SERVICE_URI}/ai/health; 95 | proxy_ssl_server_name on; 96 | proxy_http_version 1.1; 97 | } 98 | 99 | location /ai/generate/description { 100 | proxy_pass {PRODUCT_SERVICE_URI}/ai/generate/description; 101 | proxy_ssl_server_name on; 102 | proxy_http_version 1.1; 103 | } 104 | } -------------------------------------------------------------------------------- /aks-store-on-aca/modules/storeFrontNginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 8080; 3 | listen [::]:8080; 4 | server_name localhost; 5 | 6 | #access_log /var/log/nginx/host.access.log main; 7 | 8 | location / { 9 | root /usr/share/nginx/html; 10 | index index.html index.htm; 11 | } 12 | 13 | #error_page 404 /404.html; 14 | 15 | # redirect server error pages to the static page /50x.html 16 | # 17 | error_page 500 502 503 504 /50x.html; 18 | location = /50x.html { 19 | root /usr/share/nginx/html; 20 | } 21 | 22 | location /health { 23 | default_type application/json; 24 | return 200 '{"status":"ok","version":"1.2.0"}'; 25 | } 26 | 27 | location /order { 28 | proxy_pass {ORDER_SERVICE_URI}/; 29 | proxy_ssl_server_name on; 30 | proxy_http_version 1.1; 31 | } 32 | 33 | location /products { 34 | proxy_pass {PRODUCT_SERVICE_URI}/; 35 | proxy_ssl_server_name on; 36 | proxy_http_version 1.1; 37 | } 38 | } -------------------------------------------------------------------------------- /aks-store-on-aca/modules/virtual-network-links.bicep: -------------------------------------------------------------------------------- 1 | param dnsZoneName string 2 | param tags object 3 | param vnetId string 4 | 5 | resource dnsZone 'Microsoft.Network/privateDnsZones@2020-06-01' existing = { 6 | name: dnsZoneName 7 | } 8 | 9 | resource vnetLink 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2020-06-01' = { 10 | name: '${dnsZone.name}-link' 11 | parent: dnsZone 12 | location: 'global' 13 | properties: { 14 | registrationEnabled: false 15 | virtualNetwork: { 16 | id: vnetId 17 | } 18 | } 19 | tags: tags 20 | } 21 | -------------------------------------------------------------------------------- /aks-store-on-aca/parameters/dev.bicepparam: -------------------------------------------------------------------------------- 1 | using '../main.bicep' 2 | 3 | param acaResourceGroupName = 'rg-aca-${locationPrefix}-${environment}' 4 | param environment = 'dev' 5 | param openAILocation = 'francecentral' 6 | param location = 'northeurope' 7 | param locationPrefix = 'neu' 8 | 9 | param tags = { 10 | application: 'aca-store' 11 | environment: environment 12 | } 13 | 14 | param vnetIpRange = '10.0.0.0/21' 15 | 16 | param subnets = [ 17 | { 18 | name: 'snet-aca-${environment}' 19 | subnetPrefix: '10.0.0.0/23' 20 | } 21 | ] 22 | 23 | param commonResourceGroupName = 'kris-chief-rg' 24 | param commonKeyVaultName = 'kv-neu-common' 25 | -------------------------------------------------------------------------------- /aks-store-on-aca/parameters/prod.bicepparam: -------------------------------------------------------------------------------- 1 | using '../main.bicep' 2 | 3 | param acaResourceGroupName = 'rg-aca-${locationPrefix}-${environment}' 4 | param environment = 'prod' 5 | param openAILocation = 'francecentral' 6 | param location = 'northeurope' 7 | param locationPrefix = 'neu' 8 | 9 | param tags = { 10 | application: 'aca-store' 11 | environment: environment 12 | } 13 | 14 | param vnetIpRange = '10.0.0.0/21' 15 | 16 | param subnets = [ 17 | { 18 | name: 'snet-aca-${environment}' 19 | subnetPrefix: '10.0.0.0/23' 20 | } 21 | ] 22 | 23 | param commonResourceGroupName = '' 24 | param commonKeyVaultName = '' 25 | -------------------------------------------------------------------------------- /static/images/aks-store-on-aca-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guidemetothemoon/azure-container-apps-lab/639309f4d7b058c0fac2eb7e818f2a17aa238a46/static/images/aks-store-on-aca-architecture.png --------------------------------------------------------------------------------