标签: azure-static-web-app

Azure静态Web应用程序环境变量

我正在尝试通过 Azure Static Web 应用程序发布 Gatsbyjs。我有一个插件(gatsby-source-contentful)。

我需要传递如下变量:

{
      resolve: `gatsby-source-contentful`,
      options: {
        spaceId: process.env.CONTENTFUL_SPACE_ID,
        accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
      },
},
Run Code Online (Sandbox Code Playgroud)

错误:

Running 'npm run build'...


> gatsby-starter-default@0.1.0 build /github/workspace
> gatsby build

success open and validate gatsby-configs - 0.021s
error Invalid plugin options for "gatsby-source-contentful":

- "accessToken" is required
- "spaceId" is required
not finished load plugins - 0.905s
Run Code Online (Sandbox Code Playgroud)

我可以在哪里通过这个?

谢谢。

environment-variables node.js contentful gatsby azure-static-web-app

5
推荐指数
2
解决办法
9720
查看次数

azure static web“Oryx 构建了应用程序文件夹,但无法确定应用程序工件的位置。请指定应用程序工件位置”

我在github上有一个简单的index.html。我在 azure 中创建了一个静态 Web 应用程序并将其指向 git hub。它运行某种构建管道,并且我的页面正常运行。

现在我添加了更多页面,但是当我推送到 git 时,静态 Web 应用程序构建失败并显示:

Oryx 构建了应用程序文件夹,但无法确定应用程序工件的位置。请指定应用程序工件位置。

很多人都有同样的问题,一般建议是设置 api_location,但我找不到指定的位置。

我找不到任何构建脚本,而且我当然没有足够的知识从头开始编写一个脚本。

构建脚本大概只需要对 git 文件进行简单的签出。

更新

在寻找解决方案时,我发现了一个隐藏在 .github 下的 yaml 文件。

它具有以下特点:

      app_location: "/" # App source code path
      api_location: "" # Api source code path - optional
      output_location: "" # Built app content directory - optional
Run Code Online (Sandbox Code Playgroud)

这并没有真正的帮助,因为“应用程序工件”是什么以及它应该去哪里并不明显。

有什么建议么?

azure-static-web-app

5
推荐指数
1
解决办法
5394
查看次数

如何在 Angular 中访问 Azure 静态 Web 应用程序应用程序设置?

我将 Angular 应用程序作为静态 Web 应用程序部署到 Azure 中。现在我想使用配置中的应用程序设置来更改环境中的变量。ts 来访问不同的 API 和 Application Insights,而无需每次都更改代码。

在此输入图像描述

环境.ts

export const environment = {
  production: true,
  SERVER_API_URL: 'https://backend01.azurewebsites.net',
  DEVELOPER_OPTIONS: true,
  ENABLE_PROD_MODE: true,

  appInsights: {
    instrumentationKey: '<key>'
}
};
Run Code Online (Sandbox Code Playgroud)

我想改变instrumentationKeySERVER_API_URL。这可以通过应用程序设置实现吗?有人知道如何做到这一点吗?

谢谢 :)

azure application-settings angular azure-static-web-app static-web-apps

5
推荐指数
1
解决办法
1990
查看次数

如何将 Azure DevOps Git 存储库与 Azure 静态 Web 应用程序结合使用?

Azure 有一个新的静态托管产品,这将非常有用。这个想法是您可以将静态站点代码签入 Git,并将其部署到您的站点。您甚至可以将分支视为一种预览工作流程。

问题是 Azure 静态 Web 服务似乎仅适用于 Github。

我们的组织在 Azure DevOps 中拥有所有存储库,这是我们的存储库、构建管道和 Azure Web 服务的无缝统一环境。我们所有的开发人员都使用 Azure Dev ops git 帐户进行设置,他们没有(非私人)github 帐户。

我们不想在 Azure 之外设置重复的 git 托管 - 以及安全、授权或与 Active Directory 链接的痛苦。

我们希望将 Azure Git 与 Azure Static Web 结合使用。

在很大程度上,git 就是 git。

有没有人有任何解决方法、技巧或教程来使这两个 Microsoft Azure 产品相互通信?

azure azure-devops azure-static-web-app

3
推荐指数
1
解决办法
2306
查看次数

任务 AzureStaticWebApp@0“无法检测到此目录”但已呈现

我正在使用 AzureDevOps 构建管道,但遇到了一个奇怪的问题。

这是我的管道:

- stage: 'Test'
  displayName: 'Deploy to the test environment'
  dependsOn: Build
  jobs:
    - job: 'Deploy'
      steps:
      - download: current
        artifact: lorehub-front
      - bash: cd $(Pipeline.Workspace); echo $(ls)
      - bash: cd $(Pipeline.Workspace)/lorehub-front; echo $(ls)
      - task: AzureStaticWebApp@0
        displayName: 'Publish to Azure Static WebApp'
        inputs:
          app_location: $(Pipeline.Workspace)/lorehub-front
          azure_static_web_apps_api_token: xxxx
Run Code Online (Sandbox Code Playgroud)

第一个 bash 显示存在文件夹“lorehub-front”

第二个 bash 显示内部文件夹是正确的文件(index.html 等)

脚本内容:cd /home/vsts/work/1/lorehub-front;回声 $(ls)

android-chrome-192x192.png android-chrome-512x512.png apple-touch-icon.png css env-config.js favicon-16x16.png favicon-32x32.png favicon.ico 字体 index.html js site.webmanifest

但我收到此错误:

应用程序目录位置:“/home/vsts/work/1/lorehub-front”无效。无法检测到该目录。请验证您的部署配置文件反映了您的存储库结构。

azure-devops azure-pipelines azure-static-web-app

3
推荐指数
1
解决办法
3589
查看次数

如何在 Azure Devops 版本部署 Azure 静态 Web 应用中找到我的 staticwebapp.config.json?

我有一个为我的Angular应用程序构建 artificat 的管道。在我尝试访问特定 URL 之前,部署工作正常。它将我重定向到 404。这与staticwebapp.config.json. 看起来像:

{
  "navigationFallback": {
    "rewrite": "/index.html",
    "exclude": ["*.{css,scss,js,png,gif,ico,jpg,svg}"]
  }
}
Run Code Online (Sandbox Code Playgroud)

我在 Azure Devops 中创建了一个发布管道,将其发布到Azure 上的静态 Web 应用程序。这就是我的.yaml样子:

steps:
- task: AzureStaticWebApp@0
  displayName: 'Static Web App: '
  inputs:
    workingDirectory: '$(System.DefaultWorkingDirectory)/xx/xx/xx-xx-web'
    app_location: /
    output_location: dist
    config_file_location: configuration
    skip_app_build: true
    skip_api_build: true
    is_static_export: false
    verbose: true
    azure_static_web_apps_api_token: 'SOMEVALUE'
Run Code Online (Sandbox Code Playgroud)

staticwebapp.config.json 位于此处:

  • 源代码
    • 应用程序
    • 资产
    • 配置
      • 静态webapp.config.json

这是我在发布过程中遇到的错误:

##[error]routes_location: route file 'staticwebapp.config.json/routes.json' could not be found.
Run Code Online (Sandbox Code Playgroud)

或者当我填写config_file_location

##[error]config_file_location: config file …
Run Code Online (Sandbox Code Playgroud)

azure-devops angular azure-static-web-app azure-static-web-app-routing

3
推荐指数
1
解决办法
3785
查看次数

如何在 MSAL 的 redirectUri 中使用相对 url?

在作为静态 Web 应用程序托管在 Azure 上的 React 应用程序中,我使用 MSAL 库进行身份验证。为了创建新的 Msal.UserAgentApplication,我需要传递一个配置对象 - 特别是包含redirectUri。就像是:

const msalConfig = {
   auth: {
      clientId: "75d84e7a-40bx-f0a2-91b9-0c82d4c556aa", 
      authority: "https://login.microsoftonline.com/common",
      redirectUri: "www.example.org/start",
   },
   ...
Run Code Online (Sandbox Code Playgroud)

我想知道:如何使用相对重定向网址,而不是绝对重定向网址?

我试图解决的具体问题如下:当我在本地启动并测试应用程序时,我想重定向到localhost:3000/start而不是www.example.org/start。到目前为止,我还没有找到比每次运行/部署之前切换配置文件更好的方法,但这很烦人,当然很容易忘记......

javascript azure reactjs azure-ad-msal azure-static-web-app

2
推荐指数
1
解决办法
2537
查看次数

我可以在 Blazor 静态 Web 应用程序 WASM 的内置 OIDC 身份验证调用上指定回调 URL 吗?

我从 Blazor 静态 Web 应用程序调用“/.auth/login/google”(或其他提供商)。一旦用户同意,控制权将被路由回索引页面。有没有办法指定我想要不同的返回页面,例如通过“/.auth/login/google?callback=http...”之类的内容?

openid-connect azure-web-app-service blazor blazor-webassembly azure-static-web-app

2
推荐指数
1
解决办法
621
查看次数

应用程序构建无法生成工件文件夹 Angular Azure 静态 Web 应用程序部署问题

当我尝试使用 azure devops 构建角度应用程序并部署到 azure 静态 Web 应用程序时,我收到以下错误

应用程序构建无法生成工件文件夹:“dist/harmony-front”。请确保在部署配置文件中正确配置此属性。

在此输入图像描述

我尝试通过改变output_location to / , dist, /dist , dist/harmony-front,

似乎没什么用

这是部署部分的 yaml 代码

- task: AzureStaticWebApp@0
  inputs:
      app_location: "/"
      api_location: "api"
      output_location: "./dist/harmony-front"
      app_build_command: 'npm run build:prod'
      skip_api_build: true
      verbose: true

  env:
      continueOnError: true
      CUSTOM_BUILD_COMMAND: "npm install --force"
      azure_static_web_apps_api_token: $(deployment_token)
Run Code Online (Sandbox Code Playgroud)

我犯了什么错误

谢谢

azure azure-devops azure-static-web-app

2
推荐指数
1
解决办法
2847
查看次数

带有 Vue 项目路由的 Azure 静态 Web 应用程序不起作用

我有一个使用 Azure 静态 Web 应用程序部署的 vue 项目。项目包含路由器(历史模式)功能。它在本地运行完美。但是在部署到 Azure 路径后,链接无法正常工作。例如,当我尝试从浏览器导航访问 mysite.com/about 时,它返回 404 错误。

公共文件夹中的 staticwebapp.config.json 文件:(我从 microsoft docs 中获取此示例)

{
    "routes": [
      {
        "route": "/*",
        "serve": "/index.html",
        "statusCode": 200
      }
    ]
  }
Run Code Online (Sandbox Code Playgroud)

我的路由器js文件:

import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/api',
    name: 'Api',
    component: () => …
Run Code Online (Sandbox Code Playgroud)

router azure vue.js vue-router azure-static-web-app

1
推荐指数
2
解决办法
449
查看次数