Stwórz aplikację do modelu semantycznego w GitHub Copilot

Użyj tego przepisu, aby stworzyć aplikację analityczną połączoną z modelem semantycznym w trybie GitHub agent funkcji Copilot. Copilot tworzy szablon aplikacji danych, dodaje złącze semantycznego modelu Fabric, tworzy zapytania i wizualizacje DAX oraz weryfikuje aplikację.

Szablon aplikacji danych zapewnia uwierzytelnianie Fabric, wskazówki dotyczące generowania DAX, komponenty wizualne oraz walidację przeglądarki. Konektor zapewnia delegowany dostęp do modelu semantycznego za pośrednictwem klienta Fabric Apps. Aby uzyskać więcej informacji, zobacz Tworzenie aplikacji połączonej z modelem semantycznym.

W tym samouczku nauczysz się następujących rzeczy:

  • Przygotuj GitHub Copilot do rozwoju opartego na agentach.
  • Poproś Copilota o utworzenie szablonu aplikacji danych.
  • Połącz aplikację z modelem semantycznym.
  • Stwórz interaktywny eksplorator wydajności sprzedaży.
  • Przejrzyj i zweryfikowaj wygenerowane zmiany.
  • Wdroż aplikację na Fabric.
  • Zweryfikowaj wdrożenie i otwórz aplikację.

Wymagania wstępne

  • Node.js 20 lub nowszy.
  • Visual Studio Code.
  • GitHub Copilot w Visual Studio Code z dostępnym trybem agenta.
  • Konto GitHub z dostępem do GitHub Copilot.
  • konto Microsoft z dostępem do Fabric.
  • Obszar roboczy Fabric, w którym masz uprawnienia Współautor, Członek lub Administrator.
  • Obciążenie Fabric Apps jest włączone dla Twojego tenanta.
  • Ustawienie dzierżawy interfejsu API REST wykonywania zapytań semantycznego modelu jest włączone.
  • Uprawnienia do kompilowania i odczytu modelu semantycznego hostowanego w usłudze Fabric lub w pojemności usługi Power BI.
  • ID przestrzeni roboczej i ID elementu dla modelu semantycznego.

Note

Copilot prosi o zatwierdzenie przed uruchomieniem poleceń terminala. Musisz także wykonać interaktywne logowanie do przeglądarki, gdy CLI Rayfin o to wymaga.

Otwórz tryb agent funkcji Copilot na GitHubie

  1. Otwórz program Visual Studio Code.
  2. Otwórz folder nadrzędny, w którym chcesz, aby Copilot stworzył projekt.
  3. Otwórz czat.
  4. Wybierz tryb Agent.
  5. Potwierdź, że agent ma dostęp do terminala i miejsca pracy.

Nie otwieraj folderu zawierającego niepowiązane pliki, których nie chcesz, żeby Copilot przeglądał lub modyfikował.

Wygeneruj szkielet aplikacji danych

Skopiuj poniższy prompt do Copilot Chat:

Set up a new Fabric data app for me, end to end.

Create the project in a folder named sales-insights. Before changing code, read any
copilot-instructions.md files and agent guidance included in the scaffolded project.

Do the work yourself instead of only printing instructions:
1. Run `npm create @microsoft/rayfin@latest -- "sales-insights" --template dataapp --workspace <workspace-name>`.
2. In the scaffolded project, run `npx rayfin connector add --type fabric-semanticmodel --workspace-id <workspace-id> --item-id <semantic-model-item-id> --name salesModel --operations executeQuery`.
3. Run the version-matched npm install command printed by the connector command.
4. Open and inspect the scaffolded project. Explain the data app template's DAX query,
   visualization, data grid, theme, and browser-validation patterns.
5. Configure the template to use ConnectorsRayfinClient, the generated salesModel
   schema, and the fabricSemanticModel() runtime. Don't retain or add a direct
   Execute Queries REST API client.
6. If authentication is required, run `npx rayfin login` and pause while I complete
   sign-in.
7. Run the existing build and report any errors.
8. Summarize the scaffolded app and wait for my semantic model requirements.

Ask before making a destructive change or using a force option.

Zastąp <workspace-name>, <workspace-id>, i <semantic-model-item-id> wartościami dla przestrzeni roboczej Fabric i modelu semantycznego. Zatwierdzaj polecenia w momencie, gdy Copilot je wykonuje, i kończ proces logowania Rayfin, gdy zostanie o to poproszony.

Zapytaj funkcję Copilot o stworzenie Twojej aplikacji

Opisz grupę odbiorców aplikacji, pytania, interakcje i wizualizacje. Łącznik salesModel już identyfikuje model semantyczny.

Użyj poniższego promptu jako podstawowego przepisu na badanie wydajności sprzedaży. Dostosuj wymagania biznesowe do obszarów dostępnych w Twoim modelu.

Use the existing salesModel connector to build a sales performance explorer for
sales managers.

Requirements:
- Inspect the generated connector schema and semantic model metadata before editing.
  Use actual table, measure, and column names instead of guessing them.
- Show KPI callouts for the model's revenue, order volume, and margin measures when
  those measures are available.
- Add a time-series chart for sales performance, a bar chart that compares a useful
  business category, and a detailed data grid.
- Add date and category filters, and use the template's cross-highlighting behavior.
- Use the template's DAX generation patterns and visual primitives. Minimize the
  number of DAX queries and don't duplicate queries for the same data.
- Submit DAX with client.connectors.salesModel.executeQuery(), check the returned
  status, and handle success and error results.
- Apply the semantic model's format strings consistently to cards, charts, tooltips,
  and the data grid.
- Include loading, empty, and error states.
- Don't add mock data, embed credentials, or implement a separate authentication flow.
- Preserve the template's Fabric authentication and the semantic model connector.
- Don't add dependencies unless they're necessary.

Before editing, inspect the relevant files and give me a short implementation plan.
Ask me to clarify any model fields that are ambiguous. Then make the changes, run
the existing build, and use the template's browser validation workflow to check the
layout at desktop and mobile sizes. Explain any errors you fix.

Przejrzyj plan Copilot, zanim zedytuje projekt. Jeśli plan nie spełnia Twoich wymagań, popraw go na czacie przed zatwierdzeniem realizacji.

Przeglądanie wygenerowanych zmian

Gdy Copilot zakończy pracę, poproś go, aby przejrzał swoją pracę:

Review the changes you made against every requirement in my previous prompt.

Check for:
- DAX queries that reference fields that aren't in the semantic model.
- Duplicate or unnecessary DAX queries.
- Hard-coded sample data, credentials, access tokens, or a second sign-in flow.
- Formatting that ignores the semantic model's format strings.
- Charts, filters, cross-highlighting, or data grid interactions that don't work.
- Missing loading, empty, or error states.
- TypeScript or build errors.

Fix confirmed issues, run the existing build and browser validation, and summarize
the final behavior.

Sprawdź różnice w kontroli źródła w Visual Studio Code. Zwróć szczególną uwagę na:

  • Konfiguracja salesModel złącza, generowany schemat oraz zapytania DAX.
  • Konfiguracja usług w rayfin/rayfin.yml.
  • Nowe zależności w package.json.
  • Zmiany uwierzytelniania lub bezpośrednie wywołania REST, które omijają konektor.
  • Sekrety lub dokumenty, których nie wolno ujawniać.

Wdrożenie i weryfikacja połączenia modelu semantycznego

Zapytaj funkcję Copilot o wdrożenie aplikacji i weryfikację jej połączenia:

Deploy the app with `npx rayfin up`, then run `npx rayfin up status` and confirm
that the deployment is healthy. Give me the Fabric portal link from the command
output.

Don't add mock data if a semantic model query fails. Check the workspace and model
IDs in the connector configuration, the Semantic Model Execute Queries REST API
tenant setting, my Build and Read permissions, the DAX query, the connector error
result, and the browser console. Report the exact failure and the corrective action.

Otwórz aplikację z portalu Fabric, aby przetestować na żywo zapytania dotyczące modeli semantycznych.

Weryfikowanie aplikacji

Poproś Copilota o uruchomienie istniejącej walidacji projektu:

Validate the app without adding new tools.

1. Run the existing build and type-check commands from package.json.
2. Run the template's browser validation at desktop and mobile sizes.
3. Check for clipped charts, unreadable labels, empty visuals, and console errors.
4. Tell me which semantic model queries and user interactions I must verify in the
    Fabric portal.
5. Fix confirmed build, type, or layout errors, and rerun the failed check.

W portalu Fabric sprawdź kryteria akceptacji, które podałeś Copilotowi. Przetestuj uwierzytelnianie, filtry, wyróżnianie krzyżowe, formatowanie danych, stany puste, obsługę błędów oraz wyniki każdej wizualizacji.

Wdrożenie gotowej aplikacji

Po przejrzeniu zmian i przetestowaniu aplikacji poproś Copilot o jej wdrożenie:

Deploy the reviewed app to Fabric.

1. Show me the current git diff and summarize what will be deployed.
2. Run `npx rayfin up`.
3. Run `npx rayfin up status`.
4. Confirm that the deployment is healthy.
5. Give me the hosted app URL and Fabric portal link from the command output.

Stop and explain the issue if deployment or verification fails.

To samo npx rayfin up polecenie aktualizuje istniejące wdrożenie, gdy kontynuujesz rozwój aplikacji.

Kontynuuj iterację z Copilot

Używaj precyzyjnych promptów do późniejszych zmian. Uwzględnij pożądane zachowanie, dotkniętych użytkowników, ograniczenia oraz kroki walidacji.

Add a product detail view to the sales performance explorer.

Open the view when a user selects a product in the data grid. Use fields and measures
that exist in the semantic model, reuse existing query results where practical, and
preserve filters and formatting. Run the existing build and browser validation, then
list the interactions and DAX results I should verify in the Fabric portal.

Każde żądanie utrzymuj na tyle małe, aby można je było przejrzeć. Najpierw zaangażuj się w stan działania, zanim poprosisz Copilot o dużą lub potencjalnie destrukcyjną zmianę.

Rozwiązywanie problemów z przepływem pracy rozwiązania Copilot

Copilot drukuje tylko polecenia

Powiedz Copilotowi, żeby sam wykonał polecenia i zgłosił wyniki. Potwierdź, że czat jest w trybie agenta i dostęp do terminala jest włączony.

Na zalogowanie czeka komenda

Zakończ proces logowania do przeglądarki. Następnie powiedz Copilotowi, że logowanie się zakończyło, żeby można było kontynuować.

Copilot edytuje zły folder

Zatrzymaj agenta, otwórz folder wygenerowanego projektu w Visual Studio Code i rozpocznij nowy czat z poziomu tego obszaru roboczego.

Wdrożenie się powiodło, ale zapytania dotyczące semantycznych modeli zawodzą

Poproś aplikację Copilot, aby sprawdziła identyfikatory przestrzeni roboczej i modelu konektora, ustawienie dzierżawy dla interfejsu API REST Semantic Model Execute Queries, uprawnienia Build i Read, wygenerowany kod DAX, wynik błędu konektora oraz konsolę przeglądarki. Nie zastępuj nieudanych zapytań danymi testowymi.

Copilot proponuje --force

Wymagaj, aby Copilot najpierw wyświetlał potencjalnie destrukcyjne operacje na schemacie. Akceptuj --force tylko wtedy, gdy rozumiesz i zatwierdzasz możliwą utratę danych.

W przypadku innych problemów zobacz Troubleshoot Fabric Apps.