Files
backstage/plugins/azure-sites-backend
github-actions[bot] b228d7d9c2 Version Packages
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
2023-09-20 11:24:40 +02:00
..
2022-10-18 18:08:47 +02:00
2022-10-18 18:08:47 +02:00
2023-09-20 11:24:40 +02:00
2023-09-20 11:24:40 +02:00
2023-05-15 15:01:05 -05:00
2022-10-18 18:08:47 +02:00

Azure Sites Backend

Simple plugin that proxies requests to the Azure Portal API through Azure SDK JavaScript libraries.

Inspired by roadie.io AWS Lambda plugin

Setup

The following sections will help you get the Azure Sites Backend plugin setup and running.

Configuration

The Azure plugin requires the following YAML to be added to your app-config.yaml:

azureSites:
  domain:
  tenantId:
  clientId:
  clientSecret:
  allowedSubscriptions:
    - id:

Configuration Details:

Integrating

Here's how to get the backend plugin up and running:

  1. First we need to add the @backstage/plugin-azure-sites-backend package to your backend:

    # From your Backstage root directory
    yarn add --cwd packages/backend @backstage/plugin-azure-sites-backend
    
  2. Then we will create a new file named packages/backend/src/plugins/azure.ts, and add the following to it:

    import {
      createRouter,
      AzureSitesApi,
    } from '@backstage/plugin-azure-sites-backend';
    import { Router } from 'express';
    import { PluginEnvironment } from '../types';
    
    export default async function createPlugin(
      env: PluginEnvironment,
    ): Promise<Router> {
      return await createRouter({
        logger: env.logger,
        azureSitesApi: AzureSitesApi.fromConfig(env.config),
      });
    }
    
  3. Next we wire this into the overall backend router, edit packages/backend/src/index.ts:

    import azure from './plugins/azure';
    
    // Removed for clarity...
    
    async function main() {
      // ...
      // Add this line under the other lines that follow the useHotMemoize pattern
      const azureSitesEnv = useHotMemoize(module, () =>
        createEnv('azure-sites'),
      );
    
      // ...
      // Insert this line under the other lines that add their routers to apiRouter in the same way
      apiRouter.use('/azure-sites', await azure(azureSitesEnv));
    }
    
  4. Now run yarn start-backend from the repo root.

  5. Finally, open http://localhost:7007/api/azure-sites/health in a browser, it should return {"status":"ok"}.