Deploy to Azure with Blob Storage

Learn how to deploy your customization to Azure with Blob Storage.

Prerequisites

Before you get started, you need to have:

Configuration

Adding the customization identifier and URL

Depending on the customization type, you'll need to specify either the Custom Application ID or the Custom View ID that was provided to you when you added the customization in the Merchant Center.

You'll also need to specify 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.

For Custom Applications, make the following changes to the Custom Application config:

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

For Custom Views, make the following changes to the Custom View config:

custom-view-config.mjsJavaScript
const config = {
env: {
production: {
customViewId: 'ckvtahxl90097sys6har1e6n3',
url: 'https://<project>.z13.web.core.windows.net/',
},
},
// ...
};

Using environment variables

To avoid hardcoding values (such as the customization identifier or the Project key), you can use variable placeholders in your Custom Application config or Custom View config.

Example of environment variables with Custom Applications:

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

Example of environment variables with Custom Views:

custom-view-config.mjsJavaScript
{
"env": {
"production": {
"customViewId": "${env:CUSTOM_VIEW_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 customization 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

Install your customization in the Merchant Center to access it within your Projects: