I am using Azure SWA CLI 1.0.2 on Node 16.15.0 in WSL2 on Windows 11
Starting with a "Hello World" style deployment. E.g. no CI/CD, no Github, no repost, commits, PRs, etc.
I have my dist folder with a simple Hello World style index.html file. I can view it with the SWA dev server.
When I attempt to deploy with npx #azure/static-web-apps-cli deploy ./dist -S <REDACTED> --no-use-keychain I get the following output
Welcome to Azure Static Web Apps CLI (1.0.2)
Deploying front-end files from folder:
/myproject/dist
Checking Azure session...
✔ Successfully logged into Azure!
✔ Choose your tenant › <REDACTED>
✔ Successfully logged into Azure tenant: <REDACTED>
✔ Saved project credentials in .env file.
Checking project settings...
✔ Choose your Static Web App › >> Create a new application
✔ Choose a project name: … delme
✔ Project created successfully!
✔ Successfully setup project!
Deploying to environment: preview
Deploying project to Azure Static Web Apps...
⠙ Looking for event info
But it just sits on "Looking for event info" forever.
I have also tried with deployment tokens, killing all resources in my AZ account and starting over, etc.
Related
We have Blazor client side application that we want to deploy as Azure Static Web App.
Unfortunately Static Web App officially support Git Hub Actions and Azure DevOps as deploy options but we are using Bitbucket pipelines currently and switching to GitHub or Azure DevOps is not an option at the moment.
That is why I'm trying to deploy my blazor app to azure using Bitbucket Azure Pipes/azure-static-web-apps-deploy but for some reason it stuck on "Publishing to directory /bin/staticsites/ss-oryx/app..." step and than pipeline fails with timeout error.
Although locally "dotnet publish -c Release" executes for seconds I tried to extend the timeout to one hour with BUILD_TIMEOUT_IN_MINUTES parameter but after one hour timeout again.
Here is my bitbucket-pipelines.yml:
pipelines:
branches:
master:
- step:
name: Deploy to production
deployment: production
script:
- pipe: microsoft/azure-static-web-apps-deploy:main
variables:
APP_LOCATION: '$BITBUCKET_CLONE_DIR/App'
API_TOKEN: $deployment_token
OUTPUT_LOCATION: '$BITBUCKET_CLONE_DIR/wwwroot'
I will be thankful to any hints and suggestions how to solve that...
I'm trying to release my project using Nodejs Express on Azure Dev Ops and Deploy on Release, but when I try to open the link. I'm getting a "The page cannot be displayed because an internal server error has occurred." error.
YAML:
pool:
name: Azure Pipelines
steps:
task: NodeTool#0
displayName: 'Use Node 14.x'
inputs:
versionSpec: 14.x
task: Npm#1
displayName: 'npm install'
inputs:
verbose: false
task: Npm#1
displayName: 'npm custom'
inputs:
command: custom
verbose: false
customCommand: 'run build'
task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)'
Package Script
Webpack.config
and on Azure Pipeline
the default setting of npm install and build
and on Azure Release
All are working fine, on the build and release.
Blank Page
I'm starting to guess the problem was from the azure portal, or on the way it was setup. Because I didn't create the portal. I'm only the Contributor.
Please help clarify this.
I try to build all files on SCM \wwwroot
Make sure the index.js file is deployed to your azure app service
As you have some issues with your existing application Create the new application using this MS-DOC
Sign into Azure Pipelines. Your browser will go to to display your Azure DevOps dashboard.
Create New pipeline under the pipeline's menu of your project
Select GitHub as the source code location.
If the code is placed in GitHub, then login with Git Creds
When the list of repositories appears, select your sample Node.js repository.
Azure Pipelines analyzes the code in your repository and automatically gives a Node.js template for your pipeline. Select this template.
Azure Pipelines will automatically generates a YAML file in your pipeline. Click on Save and Run > Commit Directly to Master Branch and then choose Save ad Run again.
A new run begins. Wait for the run to complete.
The link is used to create a pipeline is azure devops Deploying a Node JS App to Azure App Service using Azure Dev-ops (Part 1)
The link will be used to deploy the Nodejs app to Azure portal using azure pipelines Deploying a Node JS App to Azure App Service using Azure Dev-ops (Part 2)
This error is a common description of the IIS server error 500. It will be difficult to find the root cause of the question with just a general description.
For more details, please Reference the SO-Thread
I am trying to host a NestJS application on Google App Engine. I'm using Cloud Build to deploy the app into App Engine after certain action on my GitHub repo.
Everything goes fine; the app builds and is deployed to App Engine. Even an instance is created for said deployment. However I cannot seem to access the host that's assigned to the service where I'm hosting the application on. I don't understand why as the test NodeJS project for App Engine ran just fine. This is what I get when trying to visit the endpoint.
app.yaml
runtime: nodejs16
instance_class: F4
service: rest
cloudbuild.yaml
steps:
- name: node:16.0.0
entrypoint: npm
args: ["install"]
- name: node:16.0.0
entrypoint: npm
args: ["run", "build"]
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy", "-v", "20220628t175507"]
timeout: "1600s"
I don't understand what I'm doing wrong. Just for reference the application is simply a REST API app, only utilized to make requests to.
Solved
GAE docs do not tell you this (they slightly hint it when talking about app.yaml's environment_variables, but not explicitly).
Make sure the port your Nest application is pointing to is process.env.PORT as GAE sets the best port available for your application automatically. Since I had a static value assigned to the port it wouldn't run.
Basically changed:
app.run(3000);
To:
app.run(process.env.PORT);
Ran latest build and everything works perfectly fine.
I am very new to the CICD.
I have to set up a pipeline to connect the GitLab repo to the cloud run.
I have currently hosted my website on cloud run and code in GitLab using the manual command.
I have tried to mind many documents and vedios but those are not very clear or I am not able to understand them. If anyone can provide me good documents or guide me, il really appreciate it.
Here's my solution for your problem:
You have to configure your Google Cloud projects:
Enable Google Cloud Run API and Cloud Build API services.
Create a Google Service Account with the correct permissions (Cloud Build Service Agent, Service Account User, Cloud Run Admin and Viewer)
Generate a credential file from your Service Account, it will output a JSON.
Setup Gitlab CI/CD variables: GCP_PROJECT_ID (with your project id) and GCP_SERVICE_ACCOUNT (with the content of your previous generated JSON).
Setup your .gitlab-ci.yml like this:
variables:
SERVICE_NAME: 'your-service-id'
image: google/cloud-sdk:latest
before_script:
- apt-get --assume-yes install npm
- npm install
- npm run build
deploy:
stage: deploy
only:
- master
script:
- echo $GCP_SERVICE_ACCOUNT > gcloud-service-key.json
- gcloud auth activate-service-account --key-file gcloud-service-key.json
- gcloud auth configure-docker
- gcloud config set project $GCP_PROJECT_ID
- gcloud config set run/region europe-west3
- gcloud run deploy $SERVICE_NAME --source . --allow-unauthenticated
If you have worked with the Gitlab CI/CD (.yml) and Cloud Run (local) before, you will understand the steps easily.
This example is assuming you have a NodeJS project.
I have a node.js website that runs fine when I run it locally with node server.js. I'm trying to deploy it online with GCP. I created a project, enabled app engine API, and gave my '#cloudbuild.gserviceaccount.com' account app engine deployer role permissions.
I also added a cloudbuild.yaml file to my repo:
steps:
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy"]
Now If I run gcloud app deploy , my build gets triggered, but appears to me causing an infinite loop of builds? For example, starting out my build log looks like this (nothing currently running):
i run gcloud app deploy and it begins a new build (1a19d9ba):
But something with this build keeps triggering new builds? in my local computer terminal, the output I get for running gcloud app deploy keeps triggering new builds:
$ gcloud app deploy
Services to deploy:
descriptor: [/mnt/c/Users/marti/Documents/projects/martinbarker/app.yaml]
source: [/mnt/c/Users/marti/Documents/projects/martinbarker]
target project: [martinbarker2]
target service: [default]
target version: [20201003t165547]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)? y
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [1a19dxxxxx627d].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/1axxx
------------------------------------------------- REMOTE BUILD OUTPUT --------------------------------------------------starting build "1a19xxxxxx27d"
FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.20xxx47:latest#160xxx288
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.202xxx547:latest#16xxx88...
| [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:
descriptor: [/workspace/app.yaml]
source: [/workspace]
target project: [martinbarker2]
target service: [default]
target version: [20201003t235749]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)?
WARNING: Unable to verify that the Appengine Flexible API is enabled for project [martinbarker2]. You may not have permission to list enabled services on this project. If it is not enabled, this may cause problems in running your deployment. Please ask the project owner to ensure that the Appengine Flexible API has been enabled and that this account has permission to list enabled APIs.
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [d0d0xxx9a987].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/d0d0xxx987?project=114941087848
----------------------------- REMOTE BUILD OUTPUT ------------------------------
starting build "d0d0dxxx987"
FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.20201xxx49:latest#160176947xx11
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.20xxx:latest#16xxx548211...
\ [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:
descriptor: [/workspace/app.yaml]
source: [/workspace]
target project: [martinbarker2]
target service: [default]
target version: [20201003t235818]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)?
WARNING: Unable to verify that the Appengine Flexible API is enabled for project [martinbarker2]. You may not have permission to list enabled services on this project. If it is not enabled, this may cause problems in running your deployment. Please ask the project owner to ensure that the Appengine Flexible API has been enabled and that this account has permission to list enabled APIs.
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [683bb8cxxx0368f36].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/683bxxxf36?project=114xx48
----------------------------- REMOTE BUILD OUTPUT ------------------------------
starting build "683bb8xx368f36"
FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.2020xxx18:latest#16xxx376
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.202xxx18:latest#16xx376...
| [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:
descriptor: [/workspace/app.yaml]
source: [/workspace]
target project: [martinbarker2]
target service: [default]
target version: [20201003t235843]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)?
WARNING: Unable to verify that the Appengine Flexible API is enabled for project [martinbarker2]. You may not have permission to list enabled services on this project. If it is not enabled, this may cause problems in running your deployment. Please ask the project owner to ensure that the Appengine Flexible API has been enabled and that this account has permission to list enabled APIs.
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [feecxxx3cd86].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/feexxx87848
----------------------------- REMOTE BUILD OUTPUT ------------------------------
starting build "feec9xxxx3cd86"
FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.2020100xxx082
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.202xxx82...
- [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:
descriptor: [/workspace/app.yaml]
source: [/workspace]
target project: [martinbarker2]
target service: [default]
target version: [20201003t235909]
target url: [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)?
This goes on, and now I have many more builds:
My app.yaml:
runtime: custom
env: flex
manual_scaling:
instances: 2
is it something with my cloudbuild.yaml file? I dont have a dockerfile in my folder
"It's not a bug; it's a feature!" But it's not documented, or I didn't find where! Actually, with App Engine Flex custom runtime, you will create a container. You can define either a cloudbuild.yaml file or a Dockerfile to describe the container creation. And this container is created with Cloud Build.
For information, if you set a specific language runtime, Buildpack is used to create the container, still on Cloud Build; however a Dockerfile is no longer required
So, in your case, as you describe, you have a cloudbuild.yaml file that deploys an App Engine flex custom runtime, that call a Cloud Build to build the container, with the cloudbuild.yaml file in parameters that deploys..... (loop!)
Ok, now, how to fix this? 2 solutions
Change the name of your cloudbuild.yaml file to not match this default naming (cloudbuild-noloop.yaml for example). Set this name in the trigger configuration or in the gcloud builds submit --config=cloudbuild-noloop.yaml command
Update your cloudbuild.yaml deploy step like this
steps:
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy","--ignore-file=cloudbuild.yaml"]