# Same branch, deploy to multiple Web Apps with Travis CI in Azure

**URL:** https://travis-ci.community/t/same-branch-deploy-to-multiple-web-apps-with-travis-ci-in-azure/12445
**Category:** v2
**Tags:** web-ui, github-integration
**Created:** [December 6, 2021, 11:15pm UTC](https://travis-ci.community/t/same-branch-deploy-to-multiple-web-apps-with-travis-ci-in-azure/12445 "2021-12-06T23:15:17Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![HILLBILLYHeisT](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/hillbillyheist/32/7476_2.png) [@HILLBILLYHeisT](https://travis-ci.community/u/HILLBILLYHeisT)
#### Post date: [December 6, 2021, 11:15pm UTC](https://travis-ci.community/t/same-branch-deploy-to-multiple-web-apps-with-travis-ci-in-azure/12445/1 "2021-12-06T23:15:17Z")

</div>

My company is working with a C# .NET Core backend and a React frontend. For deployment, I would like for both to be deployed to Azure Web Apps. So far, I have set up two web apps: one for the frontend (this being React) and one for the backend. However, I would like to only have one web app for both, and I really like Travis CI.

1. How can I deploy both on the same Azure Web App?
2. If it is not possible, how can I deploy each to separate web apps while encrypting the Travis CI environment variables (like `AZURE_WA_USERNAME` ) as different values for the branch?

My current `.travis.yml` looks like this:

```auto
jobs:
  include:
    - language: csharp
      solution: abc
      mono: none
      dotnet: 5.0.402
      before_script:
        - cd Backend
      script:
        - dotnet restore
        - dotnet test
      deploy:
        provider: azure_web_apps
        verbose: true
        on: main
    - language: node_js
      node_js:
        12
      before_install:
        - cd Frontend
      install:
        - npm install
      script:
        - npm run lint
        - npm test
        - npm run build
      deploy:
        provider: azure_web_apps
        verbose: true
        on: main

```

What can I do to make this feasible? Thanks.

---

<div class="post-metadata">

### Author: ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)
#### Post date: [December 6, 2021, 11:25pm UTC](https://travis-ci.community/t/same-branch-deploy-to-multiple-web-apps-with-travis-ci-in-azure/12445/2 "2021-12-06T23:25:59Z")

</div>

Hello @HILLBILLYHeisT,

The short version of this answer is, it’s not possible to deploy two web apps on the same app service using same app service plan.

Your second question was:

> If it is not possible, how can I deploy each to separate web apps while encrypting the Travis CI environment variables (like `AZURE_WA_USERNAME` ) as different values for the branch?

Now we _can_ do this to a degree, you’re going to have to name those environment variables differently, so example being `AZURE_WA_USERNAME` and `AZURE_WA_USERNAME2`. So in theory in your `before_script` hook, you can run this shell script I’ll write out for you, let’s name it `var.sh`:

```auto
if [["$TRAVIS_BRANCH" == "master"]]; then
  export MY_VAR=master
else
  export MY_VAR=not-master
fi

```

You can now, in your `.travis.yml` add this:

```yaml
before_script: source vars.sh

```

To use hidden `environment variables` or encrypted variables go to define variables in **Repository Settings, make sure you’re logged in, navigate to the repository , choose “Settings” from the cog menu, and click on “Add new variable” in the “Environment Variables” section.**

As an alternative to the web interface, you can also use the CLI’s [`env`](https://github.com/travis-ci/travis.rb#env) command.

By default, Travis CI will enforce deploying from your **master/main** branch.

You can explicitly specify the branch to deploy from with the _ **"on** _ option. So here’s an example:

```yaml
deploy:
  provider: azure_web_apps
  on: production

```

Let’s say you had a staging environment as well, it would be the same idea, `on` would be `on: staging` so it would look like this:

```yaml
deploy:
  provider: azure_web_apps
  on: staging

```

Hope this clears this up and give you a better scope on how to _kind of do_ what you’re asking.
