Merge pull request #23100 from deepan10/azure-site-new-backend
New backend system for Azure Site backend plugin
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-azure-sites-backend': patch
|
||||
---
|
||||
|
||||
Added new backend system for the Azure Sites backend plugin
|
||||
@@ -33,6 +33,8 @@ Configuration Details:
|
||||
|
||||
Here's how to get the backend plugin up and running:
|
||||
|
||||
#### Legacy Backend System
|
||||
|
||||
1. First we need to add the `@backstage/plugin-azure-sites-backend` package to your backend:
|
||||
|
||||
```sh
|
||||
@@ -49,14 +51,17 @@ Here's how to get the backend plugin up and running:
|
||||
} from '@backstage/plugin-azure-sites-backend';
|
||||
import { Router } from 'express';
|
||||
import { PluginEnvironment } from '../types';
|
||||
import { CatalogClient } from '@backstage/catalog-client';
|
||||
|
||||
export default async function createPlugin(
|
||||
env: PluginEnvironment,
|
||||
): Promise<Router> {
|
||||
const catalogApi = new CatalogClient({ discoveryApi: env.discovery });
|
||||
return await createRouter({
|
||||
logger: env.logger,
|
||||
azureSitesApi: AzureSitesApi.fromConfig(env.config),
|
||||
permissions: env.permissions,
|
||||
catalogApi,
|
||||
});
|
||||
}
|
||||
```
|
||||
@@ -105,6 +110,28 @@ Here's how to get the backend plugin up and running:
|
||||
}
|
||||
```
|
||||
|
||||
5. Now run `yarn start-backend` from the repo root.
|
||||
#### New Backend System
|
||||
|
||||
6. Finally, open `http://localhost:7007/api/azure/health` in a browser, it should return `{"status":"ok"}`.
|
||||
The Azure Sites backend plugin has support for the [new backend system](https://backstage.io/docs/backend-system/), here's how you can set that up:
|
||||
|
||||
In your `packages/backend/src/index.ts` make the following changes:
|
||||
|
||||
```diff
|
||||
import { createBackend } from '@backstage/backend-defaults';
|
||||
|
||||
const backend = createBackend();
|
||||
|
||||
// ... other feature additions
|
||||
|
||||
+ backend.add(import('@backstage/plugin-azure-sites-backend'));
|
||||
|
||||
// ...
|
||||
|
||||
backend.start();
|
||||
```
|
||||
|
||||
#### Start Backed & Test
|
||||
|
||||
1. Now run `yarn start-backend` from the repo root.
|
||||
|
||||
2. Finally, open `http://localhost:7007/api/azure/health` in a browser, it should return `{"status":"ok"}`.
|
||||
|
||||
@@ -7,6 +7,7 @@ import { AuthService } from '@backstage/backend-plugin-api';
|
||||
import { AzureSiteListRequest } from '@backstage/plugin-azure-sites-common';
|
||||
import { AzureSiteListResponse } from '@backstage/plugin-azure-sites-common';
|
||||
import { AzureSiteStartStopRequest } from '@backstage/plugin-azure-sites-common';
|
||||
import { BackendFeature } from '@backstage/backend-plugin-api';
|
||||
import { CatalogApi } from '@backstage/catalog-client';
|
||||
import { Config } from '@backstage/config';
|
||||
import { DiscoveryService } from '@backstage/backend-plugin-api';
|
||||
@@ -53,6 +54,10 @@ export class AzureSitesConfig {
|
||||
readonly tenantId: string;
|
||||
}
|
||||
|
||||
// @public
|
||||
const azureSitesPlugin: () => BackendFeature;
|
||||
export default azureSitesPlugin;
|
||||
|
||||
// @public (undocumented)
|
||||
export function createRouter(options: RouterOptions): Promise<express.Router>;
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
"@backstage/errors": "workspace:^",
|
||||
"@backstage/plugin-auth-node": "workspace:^",
|
||||
"@backstage/plugin-azure-sites-common": "workspace:^",
|
||||
"@backstage/plugin-catalog-node": "workspace:^",
|
||||
"@backstage/plugin-permission-common": "workspace:^",
|
||||
"@backstage/plugin-permission-node": "workspace:^",
|
||||
"@types/express": "^4.17.6",
|
||||
|
||||
@@ -17,3 +17,4 @@
|
||||
export * from './service/router';
|
||||
export * from './api';
|
||||
export * from './config';
|
||||
export { azureSitesPlugin as default } from './plugin';
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2024 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import {
|
||||
coreServices,
|
||||
createBackendPlugin,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { createRouter } from './service/router';
|
||||
import { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha';
|
||||
import { AzureSitesApi } from './api';
|
||||
|
||||
/**
|
||||
* Azure Sites Backend Plugin
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const azureSitesPlugin = createBackendPlugin({
|
||||
pluginId: 'azure-sites',
|
||||
register(env) {
|
||||
env.registerInit({
|
||||
deps: {
|
||||
config: coreServices.rootConfig,
|
||||
logger: coreServices.logger,
|
||||
httpRouter: coreServices.httpRouter,
|
||||
permissions: coreServices.permissions,
|
||||
catalogApi: catalogServiceRef,
|
||||
},
|
||||
async init({ config, logger, httpRouter, permissions, catalogApi }) {
|
||||
const azureSitesApi = AzureSitesApi.fromConfig(config);
|
||||
httpRouter.use(
|
||||
await createRouter({
|
||||
logger: loggerToWinstonLogger(logger),
|
||||
azureSitesApi,
|
||||
permissions,
|
||||
catalogApi,
|
||||
}),
|
||||
);
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -5008,6 +5008,7 @@ __metadata:
|
||||
"@backstage/errors": "workspace:^"
|
||||
"@backstage/plugin-auth-node": "workspace:^"
|
||||
"@backstage/plugin-azure-sites-common": "workspace:^"
|
||||
"@backstage/plugin-catalog-node": "workspace:^"
|
||||
"@backstage/plugin-permission-common": "workspace:^"
|
||||
"@backstage/plugin-permission-node": "workspace:^"
|
||||
"@types/express": ^4.17.6
|
||||
|
||||
Reference in New Issue
Block a user