Skip to content

Instantly share code, notes, and snippets.

-- Final Combined Query: List Owned Entities with Owner and Details
WITH RECURSIVE
InputParams AS (
SELECT
'group:default/org-example' AS start_ref,
'Group' AS start_kind
),
GroupHierarchy (owner_ref) AS (
SELECT ip.start_ref FROM InputParams ip WHERE ip.start_kind = 'Group'
Backstage's page structure is designed with a central layout containing the sidebar and header, which then renders the specific content for the current page (often including components from various plugins). Making a scrolling, full-width footer appear consistently inside the main content area of every single page (including plugin pages we don't control directly) is problematic. The standard layout doesn't provide a reliable hook to inject content globally into that specific inner spot. Attempting to force this with global CSS overrides is fragile and likely to break core Backstage layouts or future updates. A fixed footer bar that respects the sidebar area is a more feasible approach within this architecture.
// server/lib/azure-openai.ts
import dotenv from 'dotenv';
import OpenAI from "openai";
import { encode, decode } from "gpt-3-encoder";
// Load environment variables from .env file
dotenv.config();
interface TokenCache {
token: string;
# GitHub App Integration with Backstage: Comprehensive Analysis
## 1. Permissions & Webhook Configuration
### Minimal Required Permissions
A GitHub App used with Backstage should be granted the least privileges necessary for its tasks. Backstage's documentation outlines specific permissions needed for common use cases:
- **Reading catalog data**:
- Contents: Read-only (to fetch code and config like catalog-info.yaml)
- Commit statuses: Read-only (to view build status if needed)
For your first question, if you’re already using Azure AD for OAuth and need to get a user OAuth token without replacing your existing SSO, you typically have a few options:
1. Use the OAuth 2.0 Authorization Code Flow – Your app can authenticate users via Azure AD and request an access token with the required scopes. If your users are already authenticated through your SSO, Azure AD should provide a token without requiring them to log in again.
2. Use the On-Behalf-Of (OBO) Flow – If your app is acting on behalf of a user after they authenticate via another service, Azure AD allows you to exchange an existing token for another one with different scopes.
3. Silent Authentication via MSAL – If your app is using Microsoft Authentication Library (MSAL), you can leverage silent authentication to get an access token if the user has an active session.
It depends on what service you need the OAuth token for and whether your app is considered a first-party or third-party integration within your Azure AD setup.
F
const { OpenAI } = require('openai');
const apiKey = 'your-api-key'; // Replace with your Azure OpenAI API key (also used as bearer token)
const apiVersion = '2024-02-01'; // Valid as of March 2025
const apiBase = 'https://your-resource-name.openai.azure.com/'; // Replace with your Azure endpoint
const apiType = 'your-api-type'; // Replace with your specific apiType value (e.g., 'chat')
// Initialize the OpenAI client with Azure configuration
const openai = new OpenAI({
apiKey: apiKey, // Sets the api-key header
const fetch = require('node-fetch'); // Required for Node.js
const apiKey = 'your-api-key'; // Replace with your Azure OpenAI API key (also used as bearer token)
const apiVersion = '2024-02-01'; // Valid as of March 2025
const apiBase = 'https://your-resource-name.openai.azure.com/'; // Replace with your Azure endpoint
const apiType = 'your-api-type'; // Replace with your specific apiType value (e.g., 'chat')
async function createChatCompletion(messages) {
const response = await fetch(
`${apiBase}/openai/chat/completions?api-version=${apiVersion}&api-type=${apiType}`,
const fetch = require('node-fetch'); // Required for Node.js
const apiKey = 'your-api-key'; // Replace with your Azure OpenAI API key (also used as bearer token)
const apiVersion = '2024-02-01'; // Valid as of March 2025
const apiBase = 'https://your-resource-name.openai.azure.com/'; // Replace with your Azure endpoint
const deploymentName = 'your-deployment-name'; // Replace with your deployment name
async function createChatCompletion(messages) {
const response = await fetch(
`${apiBase}/openai/deployments/${deploymentName}/chat/completions?api-version=${apiVersion}`,
---
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: main-component
namespace: entityrelations
spec:
type: service
lifecycle: production
owner: user:default/guest
# This YAML file demonstrates minimal entities to show relationships for each of the following cards:
# - EntityConsumedApisCard: shows APIs consumed by an entity (generated from spec.consumesApis)
# - EntityProvidedApisCard: shows APIs provided by an entity (generated from spec.providesApis)
# - EntityDependsOnComponentsCard: shows dependency components (generated from spec.dependsOn with a component target)
# - EntityDependsOnResourcesCard: shows dependency resources (generated from spec.dependsOn with a resource target)
# - EntityHasSubcomponentsCard: shows subcomponents (generated from spec.subcomponentOf)
---
apiVersion: backstage.io/v1alpha1
kind: Component