@@ -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'
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="18.24 21.46 64 64" width="64" height="64"><path d="M81.837 53.85c.585-.585.487-1.7 0-2.307l-3.087-3.087-13.8-13.386c-.585-.585-1.495-.585-2.2 0-.585.585-.812 1.7 0 2.307l14.5 14.198c.585.585.585 1.7 0 2.307L62.44 68.568c-.585.585-.585 1.7 0 2.307.585.585 1.7.487 2.2 0l13.8-13.68zm-63.194 0c-.585-.585-.487-1.7 0-2.307l3.087-3.087 13.8-13.386c.585-.585 1.495-.585 2.2 0 .585.585.812 1.7 0 2.307l-14.2 14.2c-.585.585-.585 1.7 0 2.307l14.5 14.686c.585.585.585 1.7 0 2.307-.585.585-1.7.487-2.2 0L21.73 57.4z" fill="#3999c6"/><path d="M52.823 43.875L65.82 23.96H46.325L35.83 53.56l12.8.097-10.007 29.307L66.24 43.878z" fill="#fcd116"/><path d="M66.242 43.875h-13.42L65.82 23.96H55.617L44.83 48.554l12.8.097-19.007 34.3z" opacity=".3" fill="#ff8c00"/></svg>
|
||||
|
Before Width: | Height: | Size: 801 B |
@@ -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));
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -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<AzureSiteListResponse>;
|
||||
// (undocumented)
|
||||
start(request: AzureSiteStartStopRequest): Promise<void>;
|
||||
// (undocumented)
|
||||
stop(request: AzureSiteStartStopRequest): Promise<void>;
|
||||
}
|
||||
|
||||
// @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<AzureSiteListResponse>;
|
||||
// (undocumented)
|
||||
start(request: AzureSiteStartStopRequest): Promise<void>;
|
||||
// (undocumented)
|
||||
stop(request: AzureSiteStartStopRequest): Promise<void>;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export function createRouter(options: RouterOptions): Promise<express.Router>;
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
export interface Config {
|
||||
azureFunctions: {
|
||||
azureSites: {
|
||||
/** @visibility backend */
|
||||
domain: string;
|
||||
/** @visibility backend */
|
||||
|
||||
@@ -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<void> {
|
||||
@@ -73,31 +73,25 @@ export class AzureSitesApi {
|
||||
|
||||
async list(request: AzureSiteListRequest): Promise<AzureSiteListResponse> {
|
||||
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 };
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Azure Plugin
|
||||
# Azure Sites Plugin
|
||||
|
||||

|
||||
|
||||
@@ -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: <name>
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user