Skip to content

This provides sample .NET apps to be deployed onto Azure Container Apps through azd CLI

License

Notifications You must be signed in to change notification settings

devkimchi/azdevfying-dotnet-apps-on-aca

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

azdevfying .NET apps on Azure Container Apps

This provides sample .NET apps to be deployed onto Azure Container Apps through Azure Developer CLI.

Prerequisites

Architecture

Overall architecture

Three .NET apps are provided in this repository:

Getting Started

NOTE: You can see the complete example including all the Bicep files by switching to the azdevfied branch.

  1. Login to Azure through Azure Developer CLI.

    azd auth login
  2. Run the following command to initialise azd. It will ask you to choose options how to initialise. Follow the instructions.

    azd init

    Once initialised, you will have both .azure and infra directories and both next-steps.md and azure.yaml files.

    At this stage, the web app doesn't know where the API and Functions apps are. Therefore, you need to update the main.bicep file to pass the API and Functions app URLs to the web app.

  3. Open infra/main.bicep file and update the following section:

    module webApp './app/WebApp.bicep' = {
      name: 'WebApp'
      params: {
        ...
    
        // Add the following two lines
        apiEndpointUrl: apiApp.outputs.uri
        funcEndpointUrl: funcApp.outputs.uri
      }
      scope: rg
    }
  4. Open infra/app/WebApp.bicep file and add the parameters:

    ...
    @secure()
    param appDefinition object
    
    // Add the following two lines
    param apiEndpointUrl string
    param funcEndpointUrl string
    ...
  5. Update the env variable:

    // Before
    var env = map(filter(appSettingsArray, i => i.?secret == null), i => {
      name: i.name
      value: i.value
    })
    
    // After
    var env = union(map(filter(appSettingsArray, i => i.?secret == null), i => {
      name: i.name
      value: i.value
    }), [
      {
        name: 'API_ENDPOINT_URL'
        value: apiEndpointUrl
      }
      {
        name: 'FUNC_ENDPOINT_URL'
        value: funcEndpointUrl
      }
    ])
  6. Run the following command to provision and deploy all the apps to Azure Container Apps.

    azd up

    NOTE: Make sure that Docker Desktop should be up and running before entering this command.

  7. Once the deployment is completed, you will see the output like below:

    Deploying services (azd deploy)
    
      (✓) Done: Deploying service ApiApp
      - Endpoint: https://ca-apiapp-{{random-string}}.{{random-string}}.{{location}}.azurecontainerapps.io/
    
      (✓) Done: Deploying service FuncApp
      - Endpoint: https://ca-funcapp-{{random-string}}.{{random-string}}.{{location}}.azurecontainerapps.io/
    
      (✓) Done: Deploying service WebApp
      - Endpoint: https://ca-webapp-{{random-string}}.{{random-string}}.{{location}}.azurecontainerapps.io/
  8. Click the web app URL above to see the deployed web app, and navigate to the /weather page. Then you will see the screen like below:

    Web app

    The weather data is fetched from the ASP.NET Core Web API while the greetings message is fetched from the Azure Functions.

More Information

About

This provides sample .NET apps to be deployed onto Azure Container Apps through azd CLI

Resources

License

Stars

Watchers

Forks