diff --git a/microsite/data/plugins/azure-sites.yaml b/microsite/data/plugins/azure-sites.yaml index edfba635fc..8331b3eeba 100644 --- a/microsite/data/plugins/azure-sites.yaml +++ b/microsite/data/plugins/azure-sites.yaml @@ -1,9 +1,9 @@ --- -title: Azure +title: Azure Sites author: FRISS authorUrl: https://friss.com category: Infrastructure -description: View related Azure information for your components in Backstage. +description: Azure Sites (Apps & Functions) support for a given entity. View the current status of the site, quickly jump to site's Overview page, or Log Stream page. documentation: https://github.com/backstage/backstage/tree/master/plugins/azure-sites iconUrl: img/azure-icon.svg npmPackageName: '@backstage/plugin-azure-sites' diff --git a/microsite/static/img/azurefunctions-icon.svg b/microsite/static/img/azurefunctions-icon.svg deleted file mode 100644 index 0c2435bf42..0000000000 --- a/microsite/static/img/azurefunctions-icon.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/plugins/azure-sites-backend/README.md b/plugins/azure-sites-backend/README.md index b655f1fb64..5f19267499 100644 --- a/plugins/azure-sites-backend/README.md +++ b/plugins/azure-sites-backend/README.md @@ -1,4 +1,4 @@ -# Azure Backend +# Azure Sites Backend Simple plugin that proxies requests to the Azure Portal API through Azure SDK JavaScript libraries. @@ -6,14 +6,14 @@ _Inspired by [roadie.io AWS Lamda plugin](https://roadie.io/backstage/plugins/aw ## Setup -The following sections will help you get the Azure Backend plugin setup and running. +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 -azureFunctions: +azureSites: domain: tenantId: clientId: @@ -70,11 +70,13 @@ Here's how to get the backend plugin up and running: async function main() { // ... // Add this line under the other lines that follow the useHotMemoize pattern - const azureEnv = useHotMemoize(module, () => createEnv('azure')); + 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', await azure(azureEnv)); + apiRouter.use('/azure-sites', await azure(azureSitesEnv)); } ``` diff --git a/plugins/azure-sites-backend/api-report.md b/plugins/azure-sites-backend/api-report.md index 5c868ad507..751ff3f033 100644 --- a/plugins/azure-sites-backend/api-report.md +++ b/plugins/azure-sites-backend/api-report.md @@ -11,7 +11,20 @@ import express from 'express'; import { Logger } from 'winston'; // @public (undocumented) -export class AzureFunctionsConfig { +export class AzureSitesApi { + constructor(config: AzureSitesConfig); + // (undocumented) + static fromConfig(config: Config): AzureSitesApi; + // (undocumented) + list(request: AzureSiteListRequest): Promise; + // (undocumented) + start(request: AzureSiteStartStopRequest): Promise; + // (undocumented) + stop(request: AzureSiteStartStopRequest): Promise; +} + +// @public (undocumented) +export class AzureSitesConfig { constructor( domain: string, tenantId: string, @@ -26,26 +39,13 @@ export class AzureFunctionsConfig { // (undocumented) readonly domain: string; // (undocumented) - static fromConfig(config: Config): AzureFunctionsConfig; + static fromConfig(config: Config): AzureSitesConfig; // (undocumented) readonly subscriptions?: string[] | undefined; // (undocumented) readonly tenantId: string; } -// @public (undocumented) -export class AzureSitesApi { - constructor(config: AzureFunctionsConfig); - // (undocumented) - static fromConfig(config: Config): AzureSitesApi; - // (undocumented) - list(request: AzureSiteListRequest): Promise; - // (undocumented) - start(request: AzureSiteStartStopRequest): Promise; - // (undocumented) - stop(request: AzureSiteStartStopRequest): Promise; -} - // @public (undocumented) export function createRouter(options: RouterOptions): Promise; diff --git a/plugins/azure-sites-backend/package.json b/plugins/azure-sites-backend/package.json index c1f801bb71..6930f36587 100644 --- a/plugins/azure-sites-backend/package.json +++ b/plugins/azure-sites-backend/package.json @@ -4,7 +4,6 @@ "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", - "private": true, "publishConfig": { "access": "public", "main": "dist/index.cjs.js", diff --git a/plugins/azure-sites-backend/schema.d.ts b/plugins/azure-sites-backend/schema.d.ts index b94590ddb5..19a12d11a1 100644 --- a/plugins/azure-sites-backend/schema.d.ts +++ b/plugins/azure-sites-backend/schema.d.ts @@ -15,7 +15,7 @@ */ export interface Config { - azureFunctions: { + azureSites: { /** @visibility backend */ domain: string; /** @visibility backend */ diff --git a/plugins/azure-sites-backend/src/api/AzureSitesApi.ts b/plugins/azure-sites-backend/src/api/AzureSitesApi.ts index 70dc9bba69..73e92ea6a0 100644 --- a/plugins/azure-sites-backend/src/api/AzureSitesApi.ts +++ b/plugins/azure-sites-backend/src/api/AzureSitesApi.ts @@ -27,7 +27,7 @@ import { AzureSiteListResponse, AzureSiteStartStopRequest, } from '@backstage/plugin-azure-sites-common'; -import { AzureFunctionsConfig } from '../config'; +import { AzureSitesConfig } from '../config'; /** @public */ export class AzureSitesApi { @@ -35,13 +35,13 @@ export class AzureSitesApi { `https://portal.azure.com/#@${domain}/resource`; private readonly client: ResourceGraphClient; - constructor(private readonly config: AzureFunctionsConfig) { + constructor(private readonly config: AzureSitesConfig) { const creds = this.getCredentials(config); this.client = new ResourceGraphClient(creds); } - private getCredentials(config: AzureFunctionsConfig) { + private getCredentials(config: AzureSitesConfig) { return config.clientId && config.clientSecret ? new ClientSecretCredential( config.tenantId, @@ -52,7 +52,7 @@ export class AzureSitesApi { } static fromConfig(config: Config): AzureSitesApi { - return new AzureSitesApi(AzureFunctionsConfig.fromConfig(config)); + return new AzureSitesApi(AzureSitesConfig.fromConfig(config)); } async start(request: AzureSiteStartStopRequest): Promise { @@ -73,31 +73,25 @@ export class AzureSitesApi { async list(request: AzureSiteListRequest): Promise { const items: AzureSite[] = []; - try { - const result = await this.client.resources({ - query: `resources | where type == 'microsoft.web/sites' | where name contains '${request.name}'`, - subscriptions: this.config.subscriptions, + const result = await this.client.resources({ + query: `resources | where type == 'microsoft.web/sites' | where name contains '${request.name}'`, + subscriptions: this.config.subscriptions, + }); + for (const v of result.data) { + items.push({ + href: `${this.baseHref(this.config.domain)}${v.id!}`, + logstreamHref: `${this.baseHref(this.config.domain)}${v.id!}/logStream`, + name: v.name!, + kind: v.kind!, + resourceGroup: v.resourceGroup!, + subscription: v.id!.match(/\w{8}\-\w{4}\-\w{4}\-\w{4}\-\w{12}/)[0], + location: v.location!, + lastModifiedDate: v.properties.lastModifiedTimeUtc!, + usageState: v.properties.usageState!, + state: v.properties.state!, + containerSize: v.properties.containerSize!, + tags: v.properties.tags!, }); - for (const v of result.data) { - items.push({ - href: `${this.baseHref(this.config.domain)}${v.id!}`, - logstreamHref: `${this.baseHref( - this.config.domain, - )}${v.id!}/logStream`, - name: v.name!, - kind: v.kind!, - resourceGroup: v.resourceGroup!, - subscription: v.id!.match(/\w{8}\-\w{4}\-\w{4}\-\w{4}\-\w{12}/)[0], - location: v.location!, - lastModifiedDate: v.properties.lastModifiedTimeUtc!, - usageState: v.properties.usageState!, - state: v.properties.state!, - containerSize: v.properties.containerSize!, - tags: v.properties.tags!, - }); - } - } catch (ex: any) { - throw ex; } return { items: items }; } diff --git a/plugins/azure-sites-backend/src/config.ts b/plugins/azure-sites-backend/src/config.ts index 70301a17fa..3475175cb5 100644 --- a/plugins/azure-sites-backend/src/config.ts +++ b/plugins/azure-sites-backend/src/config.ts @@ -17,7 +17,7 @@ import { Config } from '@backstage/config'; /** @public */ -export class AzureFunctionsConfig { +export class AzureSitesConfig { constructor( public readonly domain: string, public readonly tenantId: string, @@ -26,10 +26,10 @@ export class AzureFunctionsConfig { public readonly clientSecret?: string, ) {} - static fromConfig(config: Config): AzureFunctionsConfig { - const azConfig = config.getConfig('azureFunctions'); + static fromConfig(config: Config): AzureSitesConfig { + const azConfig = config.getConfig('azureSites'); - return new AzureFunctionsConfig( + return new AzureSitesConfig( azConfig.getString('domain'), azConfig.getString('tenantId'), azConfig diff --git a/plugins/azure-sites/README.md b/plugins/azure-sites/README.md index 2f69518078..f240dab140 100644 --- a/plugins/azure-sites/README.md +++ b/plugins/azure-sites/README.md @@ -1,4 +1,4 @@ -# Azure Plugin +# Azure Sites Plugin ![preview of Azure table](docs/functions-table.png) @@ -12,13 +12,13 @@ _Inspired by [roadie.io AWS Lamda plugin](https://roadie.io/backstage/plugins/aw The following sections will help you get the Azure plugin setup and running -### Azure Backend +### Azure Sites Backend -You need to set up the Azure backend plugin before you move forward with any of these steps if you haven't already. +You need to set up the Azure Sites Backend plugin before you move forward with any of these steps if you haven't already. ### Entity Annotation -To be able to use the Azure plugin you need to add the following annotation to any entities you want to use it with: +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: diff --git a/plugins/azure-sites/package.json b/plugins/azure-sites/package.json index 8b9ee9f25d..2ffe0225e6 100644 --- a/plugins/azure-sites/package.json +++ b/plugins/azure-sites/package.json @@ -4,7 +4,6 @@ "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", - "private": true, "publishConfig": { "access": "public", "main": "dist/index.esm.js",