@@ -0,0 +1,7 @@
|
||||
---
|
||||
'@backstage/plugin-azure-sites': patch
|
||||
'@backstage/plugin-azure-sites-backend': patch
|
||||
'@backstage/plugin-azure-sites-common': patch
|
||||
---
|
||||
|
||||
These packages have been migrated to the [backstage/community-plugins](https://github.com/backstage/community-plugins) repository.
|
||||
@@ -1,137 +1,3 @@
|
||||
# Azure Sites Backend
|
||||
# Deprecated
|
||||
|
||||
Simple plugin that proxies requests to the Azure Portal API through Azure SDK JavaScript libraries.
|
||||
|
||||
_Inspired by [roadie.io AWS Lambda plugin](https://roadie.io/backstage/plugins/aws-lambda/)_
|
||||
|
||||
## 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:
|
||||
|
||||
```yaml
|
||||
azureSites:
|
||||
domain:
|
||||
tenantId:
|
||||
clientId:
|
||||
clientSecret:
|
||||
allowedSubscriptions:
|
||||
- id:
|
||||
```
|
||||
|
||||
Configuration Details:
|
||||
|
||||
- `domain` can be found by visiting the [Directories + Subscriptions settings page](https://portal.azure.com/#settings/directory). Alternatively you can inspect the [Azure home](https://portal.azure.com/#home) URL - `https://portal.azure.com/#@<Your_Domain>/`.
|
||||
- `tenantId` can be found by visiting [Azure Directory Overview page](https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade).
|
||||
- (Optional) `clientId` and `clientSecret` can be the same values you used for [Azure DevOps Backend](https://github.com/backstage/backstage/tree/master/plugins/azure-devops-backend) or [Azure Integration](https://backstage.io/docs/integrations/azure/org#app-registration) as long as this App Registration has permissions to read your function apps.
|
||||
- (Optional) `allowedSubscriptions` is an array of `id` that will be used to iterate over and look for the specified functions' app. `id` can be found the [Subscriptions page](https://portal.azure.com/#view/Microsoft_Azure_Billing/SubscriptionsBlade).
|
||||
|
||||
### Integrating
|
||||
|
||||
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
|
||||
# From the Backstage root directory
|
||||
yarn --cwd packages/backend add @backstage/plugin-azure-sites-backend
|
||||
```
|
||||
|
||||
2. Then we will create a new file named `packages/backend/src/plugins/azure-sites.ts`, and add the following to it:
|
||||
|
||||
```ts
|
||||
import {
|
||||
createRouter,
|
||||
AzureSitesApi,
|
||||
} 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,
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
3. Next we wire this into the overall backend router, edit `packages/backend/src/index.ts`:
|
||||
|
||||
```ts
|
||||
import azureSites from './plugins/azure-sites';
|
||||
|
||||
// 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 azureSites(azureSitesEnv));
|
||||
}
|
||||
```
|
||||
|
||||
4. Enable permissions and that the below is just an example policy that forbids anyone but the owner of the catalog entity to trigger actions towards a site tied to an entity, edit your `packages/backend/src/plugins/permission.ts`
|
||||
|
||||
```diff
|
||||
// packages/backend/src/plugins/permission.ts
|
||||
+ import { azureSitesActionPermission } from '@backstage/plugin-azure-sites-common';
|
||||
...
|
||||
class TestPermissionPolicy implements PermissionPolicy {
|
||||
- async handle(): Promise<PolicyDecision> {
|
||||
+ async handle(request: PolicyQuery, user?: BackstageIdentityResponse): Promise<PolicyDecision> {
|
||||
if (isPermission(request.permission, azureSitesActionPermission)) {
|
||||
return createCatalogConditionalDecision(
|
||||
request.permission,
|
||||
catalogConditions.isEntityOwner({
|
||||
claims: user?.identity.ownershipEntityRefs ?? [],
|
||||
}),
|
||||
);
|
||||
}
|
||||
...
|
||||
return {
|
||||
result: AuthorizeResult.ALLOW,
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
#### New Backend System
|
||||
|
||||
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"}`.
|
||||
This package has been moved to the [backstage-community/plugins](https://github.com/backstage/community-plugins) repository. Migrate to using `@backstage-community/plugin-azure-sites-backend` instead.
|
||||
|
||||
@@ -1,35 +1,39 @@
|
||||
{
|
||||
"name": "@backstage/plugin-azure-sites-backend",
|
||||
"version": "0.3.4",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"license": "Apache-2.0",
|
||||
"backstage": {
|
||||
"role": "backend-plugin",
|
||||
"moved": "@backstage-community/plugin-azure-sites-backend"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"main": "dist/index.cjs.js",
|
||||
"types": "dist/index.d.ts"
|
||||
},
|
||||
"backstage": {
|
||||
"role": "backend-plugin"
|
||||
},
|
||||
"keywords": [
|
||||
"backstage",
|
||||
"azure"
|
||||
],
|
||||
"homepage": "https://backstage.io",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/backstage/backstage",
|
||||
"directory": "plugins/azure-sites-backend"
|
||||
},
|
||||
"keywords": [
|
||||
"backstage",
|
||||
"azure"
|
||||
"license": "Apache-2.0",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"start": "backstage-cli package start",
|
||||
"build": "backstage-cli package build",
|
||||
"lint": "backstage-cli package lint",
|
||||
"test": "backstage-cli package test",
|
||||
"clean": "backstage-cli package clean",
|
||||
"lint": "backstage-cli package lint",
|
||||
"prepack": "backstage-cli package prepack",
|
||||
"postpack": "backstage-cli package postpack"
|
||||
"postpack": "backstage-cli package postpack",
|
||||
"start": "backstage-cli package start",
|
||||
"test": "backstage-cli package test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@azure/arm-appservice": "^14.0.0",
|
||||
@@ -53,7 +57,5 @@
|
||||
"@backstage/cli": "workspace:^",
|
||||
"@types/supertest": "^2.0.8"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
]
|
||||
"deprecated": "This package has been moved to the backstage/community-plugins repository. You should migrate to using @backstage-community/plugin-azure-sites-backend instead."
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# Deprecated
|
||||
|
||||
This package has been moved to the [backstage-community/plugins](https://github.com/backstage/community-plugins) repository. Migrate to using `@backstage-community/plugin-azure-sites-common` instead.
|
||||
@@ -3,7 +3,8 @@
|
||||
"version": "0.1.3",
|
||||
"description": "Common functionalities for the azure plugin",
|
||||
"backstage": {
|
||||
"role": "common-library"
|
||||
"role": "common-library",
|
||||
"moved": "@backstage-community/plugin-azure-sites-common"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
@@ -42,5 +43,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "workspace:^"
|
||||
}
|
||||
},
|
||||
"deprecated": "This package has been moved to the backstage/community-plugins repository. You should migrate to using @backstage-community/plugin-azure-sites-common instead."
|
||||
}
|
||||
|
||||
@@ -1,73 +1,3 @@
|
||||
# Azure Sites Plugin
|
||||
# Deprecated
|
||||
|
||||
Azure Sites (Apps & Functions) plugin support for a given entity. View the current status of the site, quickly jump to site's Overview page, or Log Stream page.
|
||||
|
||||

|
||||
|
||||
_Inspired by [roadie.io AWS Lamda plugin](https://roadie.io/backstage/plugins/aws-lambda/)_
|
||||
|
||||
## Features
|
||||
|
||||
- Azure overview table
|
||||
|
||||
## Plugin Setup
|
||||
|
||||
The following sections will help you get the Azure plugin setup and running
|
||||
|
||||
### Azure Sites Backend
|
||||
|
||||
You need to set up the [Azure Sites Backend plugin](https://github.com/backstage/backstage/tree/master/plugins/azure-sites-backend) before you move forward with any of these steps if you haven't already.
|
||||
|
||||
### Entity Annotation
|
||||
|
||||
To be able to use the Azure Sites plugin you need to add the following annotation to any entities you want to use it with:
|
||||
|
||||
```yaml
|
||||
azure.com/microsoft-web-sites: <name>
|
||||
```
|
||||
|
||||
`<name>` supports case-insensitive exact / partial value.
|
||||
|
||||
Example of Partial Matching:
|
||||
|
||||
Let's say you have a number of functions apps, spread out over different regions (and possibly different subscriptions), and they follow a naming convention:
|
||||
|
||||
```
|
||||
func-testapp-eu
|
||||
func-testapp-ca
|
||||
func-testapp-us
|
||||
```
|
||||
|
||||
The annotation you will use to have the three functions' app appear in the overview table would look like this:
|
||||
|
||||
```yaml
|
||||
azure.com/microsoft-web-sites: func-testapp
|
||||
```
|
||||
|
||||
### Install the component
|
||||
|
||||
1. Install the plugin
|
||||
|
||||
```sh
|
||||
# From your Backstage root directory
|
||||
yarn --cwd packages/app add @backstage/plugin-azure-sites
|
||||
```
|
||||
|
||||
2. Add widget component to your Backstage instance:
|
||||
|
||||
```ts
|
||||
// In packages/app/src/components/catalog/EntityPage.tsx
|
||||
import { EntityAzureSitesOverviewWidget, isAzureWebSiteNameAvailable } from '@backstage/plugin-azure-sites';
|
||||
|
||||
...
|
||||
|
||||
const serviceEntityPage = (
|
||||
<EntityLayout>
|
||||
//...
|
||||
<EntityLayout.Route if={e => Boolean(isAzureWebSiteNameAvailable(e))} path="/azure" title="Azure">
|
||||
<EntityAzureSitesOverviewWidget />
|
||||
</EntityLayout.Route>
|
||||
//...
|
||||
</EntityLayout>
|
||||
);
|
||||
```
|
||||
This package has been moved to the [backstage-community/plugins](https://github.com/backstage/community-plugins) repository. Migrate to using `@backstage-community/plugin-azure-sites` instead.
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"name": "@backstage/plugin-azure-sites",
|
||||
"version": "0.1.23",
|
||||
"backstage": {
|
||||
"role": "frontend-plugin"
|
||||
"role": "frontend-plugin",
|
||||
"moved": "@backstage-community/plugin-azure-sites"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
@@ -64,5 +65,6 @@
|
||||
"react": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
||||
"react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
||||
"react-router-dom": "6.0.0-beta.0 || ^6.3.0"
|
||||
}
|
||||
},
|
||||
"deprecated": "This package has been moved to the backstage/community-plugins repository. You should migrate to using @backstage-community/plugin-azure-sites instead."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user