Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
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:
domaincan be found by visiting the Directories + Subscriptions settings page. Alternatively you can inspect the Azure home URL -https://portal.azure.com/#@<Your_Domain>/.tenantIdcan be found by visiting Azure Directory Overview page.- (Optional)
clientIdandclientSecretcan be the same values you used for Azure DevOps Backend or Azure Integration as long as this App Registration has permissions to read your function apps. - (Optional)
allowedSubscriptionsis an array ofidthat will be used to iterate over and look for the specified functions' app.idcan be found the Subscriptions page.
Integrating
Here's how to get the backend plugin up and running:
-
First we need to add the
@backstage/plugin-azure-sites-backendpackage to your backend:# From your Backstage root directory yarn add --cwd packages/backend @backstage/plugin-azure-sites-backend -
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), }); } -
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)); } -
Now run
yarn start-backendfrom the repo root. -
Finally, open
http://localhost:7007/api/azure-sites/healthin a browser, it should return{"status":"ok"}.