Blazor Azure Static Web App not executing Javascript - javascript

I'm using a little bit of Javascript in my Blazor app to do some light work. Everything works fine on my local computer. When I publish to my Azure Static Web App, the Javascript does not execute. Here is the error message.
Refused to execute script from 'https://fullUrl/js.download' because its MIME type ('application/octet-stream') is not executable, and strict MIME type checking is enabled.
Here is my yaml file.
trigger:
- main
pool:
vmImage: ubuntu-latest
# vmImage: windows-latest
steps:
- checkout: self
submodules: true
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
publishWebProjects: true
- task: AzureStaticWebApp#0
inputs:
app_location: '/'
api_location: ''
output_location: 'wwwroot'
azure_static_web_apps_api_token: $(deployment_token)
I placed this in my staticwebapp.config.json file.
"mimeTypes": {
".json": "text/json",
".js": "application/octet-stream"
}
Does anyone know how to get this to work? Thanks!

I finally got all of this to work. I renamed myfile.js.download to just myfile.js. I then changed another js file to js.js. Anyway, that seemed to be the change that was needed.
Here is the updated yaml file.
trigger:
- master
pool:
vmImage: ubuntu-latest
# vmImage: windows-latest
steps:
- task: DotNetCoreCLI#2
displayName: 'dotnet build'
inputs:
command: 'build'
arguments: '--configuration Release'
projects: 'YourProjectName.csproj'
- task: DotNetCoreCLI#2
displayName: 'dotnet publish'
inputs:
command: 'publish'
publishWebProjects: true
arguments: '--configuration Release'
zipAfterPublish: false
- task: AzureStaticWebApp#0
inputs:
skip_app_build: true
app_location: '/bin/Release/net5.0/publish/wwwroot'
output_location: ''
azure_static_web_apps_api_token: 'YOURDEPLOYMENTTOKEN'

Related

Create GitHub action with extra resource for Javascript

I have built a GitHub Action with the Javascript "method".
I have the following action.yaml file:
name: 'xxx Action'
author: 'xxx'
description: 'Runs `xxx` in your repository.'
branding:
icon: 'code'
color: 'purple'
inputs:
token:
description: 'Txxxxunt'
required: true
groupId:
description: 'xxxx'
required: true
runs:
using: 'node16'
main: './build/index.js'
This is how my build folder looks like:
My index.js must use the keytar.node file. Is there a way to include this extra file in the action as well?
I know that GitHub will run the build/index.js file but it will fail because it will miss the extra file.
Is there a way to include this file Only With Javascript method? I do know I could do the same with Docker method

Lint only the pushed commit file on azure pipeline

I am trying to lint only the pushed files but the following yaml file only validates the whole codebase not the pushed file.
trigger:
- development-test
pool:
vmImage: ubuntu-latest
stages:
- stage: PreDeployment
jobs:
- job: Code_Validation
steps:
- script: |
docker pull github/super-linter:latest
displayName: Pull github/super-linter docker image
- script: |
docker run \
-e VALIDATE_CODE_BASE=false
-v $(System.DefaultWorkingDirectory):/tmp/lint github/super-linter
displayName: super-linter validation
Your env VALIDATE_CODE_BASE should be VALIDATE_ALL_CODEBASE
from https://github.com/github/super-linter#environment-variables :
ENV VAR
Default Value
Notes
...
...
...
VALIDATE_ALL_CODEBASE
true
Will parse the entire repository and find all files to validate across all types. NOTE: When set to false, only new or edited files will be parsed for validation.
...
...
...

Jenkins - Deploy a Yaml file to Kubernetes from Pipeline Error

I cannot resolve an issue that I was stuck with in my beginner tutorial. When I try to create just a deployment on Kubernetes from Jenkins, I got the error message.
According to my research, Jackson 2 API v2.10.0, Kubernetes v1.21.3, Kubernetes Client API v4.6.3-1, Kubernetes Continuous Deploy v2.1.2,
and I need to use Kubernetes Credentials v0.5.0 plug-ins. I don't know how can I do this?
How can I solve this problem? Could anyone pls help me?
Error
Starting Kubernetes deployment
Loading configuration: /var/lib/jenkins/workspace/k8sdeploy/k8sdeploy.yml
ERROR: ERROR: Can't construct a java object for tag:yaml.org,2002:io.kubernetes.client.openapi.models.V1Deployment; exception=Class not found: io.kubernetes.client.openapi.models.V1Deployment
in 'reader', line 1, column 1:
apiVersion: apps/v1
^
hudson.remoting.ProxyException: Can't construct a java object for tag:yaml.org,2002:io.kubernetes.client.openapi.models.V1Deployment; exception=Class not found: io.kubernetes.client.openapi.models.V1Deployment
in 'reader', line 1, column 1:
apiVersion: apps/v1
^
My Pipeline
pipeline {
agent any
stages {
stage('Clone App from Github') {
steps {
git credentialsId: 'github', url: 'https://github.com/eneslanpir/k8sdeploy'
}
}
stage("Wait For 5 Seconds"){
steps {
sleep 5
}
}
stage("Kubernetes Create Deployment"){
steps{
script {
kubernetesDeploy(configs: "k8sdeploy.yml", kubeconfigId: "kubeconfig")
}
}
}
}
}
My Deployment yaml from Github (Tested - Working on Kuberentes)
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment-jenkins
spec:
selector:
matchLabels:
app: nginx
replicas: 1
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx-jenkins
image: nginx:1.16.1
ports:
- containerPort: 80
When downgrade to Jackson 2 API v2.10.0, everythings are going wrong.
I solved the problem by trying the plugins in the links below.
https://updates.jenkins.io/download/plugins/

Deploy a Javascript Policy in Keycloak 10

I've followed the Create a JAR with the scripts to deploy instruction to create a custom Javascript policy for checking user attributes and it seems to be deployed successfully, however, I can't see the policy name in the create policy dropdown. Is there any setting I need to enable for this feature?
After uploading the .jar file to /keycloak/standalone/deployments, it says WFLYSRV0010: Deployed "script.jar" (runtime-name : "script.jar") without any error. I can also see the {filename}.jar.deployed next to my script file.
Setup: I use docker-compose to launch a jboss/keycloak version 10.0.1 container. Here's my docker-compose file:
version: "3.1"
services:
keycloak:
image: jboss/keycloak
restart: always
ports:
- 8080:8080
environment:
KEYCLOAK_PASSWORD: admin
KEYCLOAK_USER: admin
volumes:
- ./deployments:/opt/jboss/keycloak/standalone/deployments
keycloak-scripts.json:
{
"policies": [
{
"name": "my-policy",
"fileName": "my-script-policy.js",
"description": "My Policy from a JS file"
}
]
}
my-script-policy.js:
var context = $evaluation.getContext();
var contextAttributes = context.getAttributes();
if (contextAttributes.containsValue('kc.client.network.ip_address', '127.0.0.1')) {
$evaluation.grant();
}
Client policy setting
Thank you in advance for any suggestions.

How to setup Flow to monitor file changes with WebPack 2.0

Is there a way to setup Flow to run with WebPack 2 watch. So that Flow would run a 'flow status' command on each WebPack successful build ?
Currently I tried:
webpack-shell-plugin.
It allows me to run shell commands before and after WebPacks build. But once a flow finds an error, it terminates the watch process.
code:
...
plugins: [
new WebpackShellPlugin({
onBuildEnd:['npm run --silent flow']
})
]
flow-status-webpack-plugin
For me it does not work. It doesn't produce nothing inside the console.
flow-babel-webpack-plugin
While this plugin did work, sadly on each build it restarts the flow server, making the flow type chasing extremely long. Also because of the server restart native flow support form Visual Studio Code and InteliJ stops working.
I solved this issue using
'flow-status-webpack-plugin'
the webpack.config looks like this:
var FlowStatusWebpackPlugin = require('flow-status-webpack-plugin');
{
...
plugins: [
new FlowStatusWebpackPlugin({
onError: function(stdout) {
console.log(stdout)
},
onSuccess: function(stdout){
console.log(stdout)
},
restartFlow: false,
failOnError: true,
binaryPath: './node_modules/.bin/flow'
})
]
}

Categories