Deploying to Azure with Blob Storage

This deployment example refers to Azure with Blob Storage.

Prerequisites

Before you get started, you need to have:

Configuration

In your Custom Application config, make sure to provide the Custom Application ID that you got when you configured the Custom Application in the Merchant Center.

Moreover, you need to provide the production URL from your Azure project. You can keep the standard Azure Blob Storage Static Website URL https://<project>.z13.web.core.windows.net/ or provide your custom domain.

custom-application-config.jsonjson
{
"env": {
"production": {
"applicationId": "ckvtahxl90097sys6har1e6n3",
"url": "https://<project>.z13.web.core.windows.net/"
}
}
}

Using environment variables

In case you want to avoid hardcoding certain values, for example the Application ID, or the Project key, you can use variable placeholders in your Custom Application config.

custom-application-config.jsonjson
{
"env": {
"production": {
"applicationId": "${env:APPLICATION_ID}",
"url": "https://<project>.z13.web.core.windows.net/"
}
}
}

Connect Azure Blob Storage with GitHub Actions

One of the ways to deploy to Azure is to use Blob Storage. This service allows hosting a static website, but this needs to be enabled and configured in the storage account.

Follow the steps in the Azure Storage Account creator to create a new storage account.

Configuring static website hosting

Once the storage account is created, go to Static website section of the storage account and provide the following settings:

  • Static website: enabled
  • Index document name: index.html
  • Error document path: index.html

Generating deployment credentials

Follow the Azure instruction to generate deployment credentials. This step will result with the following JSON object as output in the command-line:

{
"clientId": "598...6fe",
"clientSecret": "OfU...cmr",
"subscriptionId": "c43...c21",
"tenantId": "591...e24",
...
}

Configuring GitHub Action workflow

In your repository configure the GitHub secret named AZURE_CREDENTIALS and paste the whole JSON object from the previous step as the secret value.

As the next step, add a GitHub Action workflow. For the basic GitHub Action workflow you might want to use the following content in the yaml file or change it according to your needs:

name: Blob storage website CI
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: yarn install --immutable
- name: Building
run: yarn build
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Upload to blob storage
uses: azure/CLI@v1
with:
inlineScript: |
az storage blob delete-batch --account-name <STORAGE_ACCOUNT_NAME> --auth-mode key -s '$web' # update with your <STORAGE_ACCOUNT_NAME>
az storage blob upload-batch --account-name <STORAGE_ACCOUNT_NAME> --auth-mode key -d '$web' -s public/ # update with your <STORAGE_ACCOUNT_NAME>
- name: logout
run: |
az logout
if: always()

If your Custom Application config requires environment variables, make sure to provide them in the GitHub Action workflow file. You can define the environment variables either as plain text or using GitHub encrypted secrets.

See example below for defining environment variables for the GitHub action::

...
- name: Building
env:
APPLICATION_ID: ${{ secrets.APPLICATION_ID }}
run: yarn build

Test your deployment

In the Merchant Center you can now follow the steps to install the Custom Application and access it in your Projects.

The Custom Application won't render if you try to access it directly via the deployment URL, as it needs to be served within the Merchant Center Proxy Router.

Therefore, Preview deployments are not really useful. If you are interested in this functionality, let us know and open a support issue.