How to build and release a react application in a web api application with Azure DevOps? - reactjs

We now have two applications with two differents git respositories. The first one is in ReactJS for the front and the second one is in C# (Web Api 2) for the back. When we want to deploy on Azure, we build the front and we copy the output files to the c# project (web api project). We deploy the web api application from Visual Studio in Azure thanks to the deploy menu.
It's a little bit boring and sometimes we have errors when we change by hand the parameters relative to our differents environments.
We would like to automatize all these tasks with Azure Dev Ops. Have you ever done this kind of stuff ? And how ? Sorry, if this question seems stupid but i can't find a tutorial to build when the front and the back are not in the same git repo. Thanks in advance for your help.

You can follow below steps to build and deploy your application. I can only give a general idea and steps. The main idea is to get your front and backend source code together and build them in the same pipeline. The configurations and parameters for each tasks in the build pipeline need you to specify according to your project.
Below steps is shown in classic view pipeline. Check here for yaml view pipeline
1,Sign in to your Azure DevOps organization and navigate to your project.
2,Go to Pipelines, and then select New Pipeline, and select Use the classic editor to create a pipeline without YAML at the end of the page.
3,Walk through the steps of the wizard by first selecting as the location of your source code.
4, select a source to specify where your code is located. And continue to choose a template, here i choose ASP.NET Core(.NET Framework) template.
5, Add a powershell task to the top of your pipeline(the tasks can be drag and drop to reorder) to run the git commands to clone your front react.js code into same source folder of your backend c# code.
If your code is hosted in azure repo git. You can add below scripts in your powershell task. Make sure Allow scripts to access the OAuth token is checked
cd $(Build.SourcesDirectory)
git clone "https://$env:SYSTEM_ACCESSTOKEN#dev.azure.com/{yourAzureorganizationName}/{yourProjectname}/_git/testrepo"
6, add npm install task and npm custom task to build your react.js, You need to specify the path of Working folder that contains package.json to the folder where you cloned your reactjs code in the above powershell step. you can check steps here for reference.
7, Add a copy file task before task Visual Studio build to copy the output files from building react.js to the your c# project.
8, Configure the necessary path and parameters for Visual Studio build
task and Visual Studio test task to build and test your backend c# code.
9, Add an Azure App Service deploy task at the end to deploy to azure.
You might need to add other additional tasks to build your projects. You can also move your deployment task to release pipeline.check here for more information.
There are lots of examples and learning materials that you can find online about how to create build pipeline and how to deploy your application to azure. I suggest you can follow one example to create your build pipeline for c# project and try to edit your existing pipeline to integrate your react.js project.
Here is microsoft official documents for you to check it out. Hope you find above helpful.

Here, you can find the steps to build and release two web apps (hosting web api) and the relative front developed in ReactJS. Here's our goal :
In Azure devops, we've created a pipeline using the classic editor :
We selected our git repository and this template :
After a step of creating tasks, we obtain :
We'll describe some of these tasks. For example :
/p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactstagingdirectory)\appRetailLab" /p:DeployDefaultTarget=WebPublish
Once you've build the two web applications, you've to copy the front files in web applications. There're two tasks for that :
At last, you publish your artefacts in the drop directory within the build.artifactstagingdirectory :
The release :
Our release is not too difficult :
We use 4 tasks :
Replace Token is a very usefull plugin. You can replace a token (defined by a template) by a value defined in the release. We use this plugin to replace our token in the front part of our applications (js files).
To add token in our reactjs application, we use dotenv npm package.
For the web.config parameters don't forget to check XML Variable substitution in your deploy task.
That's it.

Related

SharePoint Framework (SPFx) -- Web Part Solution Uploaded, Enabled, Not Deploying

I'm trying to deploy a custom web part solution built with SPFx to my site collection app catalog on SharePoint. When I upload the .sppkg file, I get no errors, and the web part is automatically 'enabled'. According to this Microsoft tutorial, I should at this point be prompted to deploy the web part. But I'm not getting that prompt and I can't find any option to actually deploy the thing.
Here is what my app catalog looks like post-upload:
app catalog view
This problem also happens when I try to upload/deploy the default SPFx project generated by the yeoman generator (#yo/sharepoint). This leads me to believe it's an issue with my app catalog rather than my code.
I'm using the following commands to bundle and package the solution:
gulp bundle --ship
gulp package-solution --ship
I also tried without the --ship option, no help.
Any suggestions would be appreciated, I'm desperate at this point. Thanks

How to Develop React App on Apache Webserver

i have got a problem, which i am trying to find a solution for weeks now.
I think it´s an understanding error on my side, but i couldn't figure it out.
What i am trying to do:
Develop, not deploy, a react app on an Apache2 server.
I know that react is an frontend library, so it should be possible to do.
I also know that nodeJs is kinda required to "npm" all the packages and to create the "Simple" react app..
What i want also to do:
Use the MATERIAL-UI
Build a PHP Backend
Collaborate with my Team Members (they should also work on the react app)
Thanks in advance.
Hosting a ReactJS App is no different than hosting any other javascript code on any type of server - by having it as a static file on your web server and including it in the html returned from the server.
Depending on the way your React project is set up, you would:
use node to build a javascript bundle of your react app (possibly by running "npm run build" in any CLI),
include the resulting script file or files in the head element of your root or master template
Make the Apache web server return the needed page with the master template where the script tag is
Additional setup could include starting the PHP server and react development build at the same time, but that is highly specific on your setup and would require you to add some more information on used frameworks and setup.
It is not possible to deploy apps with Apache and React. The nodejs based- Webpack server is incompatible with Apache web server. You'll have to pick one server or another, you can not route index.html -> index.tsx and vice versa. Besides if you ever got both servers working in tandem with SSL, it's a technically security nightmare and has no production value. It's best to avoid java(script) all together as it's merit in real software development has greatly diminished. Mostly for gold diggers.

Getting error when create octopus release

I am using TFS as a CI tool and using Octopus to deploy my C# Web API project. Build artifacts package pushing and creating release successfully from TFS to octopus side, But When try to deploy for IIS in Assembly server, It's getting error as like this, Please check attached error log.
The line that's throwing that error is this one in Calamari. That function Assert-WebsiteExists only gets invoked when you try to do one of the following:
A) Deploy a Web Site in IIS under an already existing Web Application.
B) Deploy a Virtual Directory in IIS under an already existing Web Application.
Both of the above will fail if the parent Web Application (in your case WKLS.Mockservice) doesn't exist before you run that step, which is apparently what's happening in your case.
If you are trying to create the Web Application from that same Octopus deployment process, then you should use this step. If you want to use a Web Application that already exists, then perhaps you just typed the name incorrectly?

Not able to download metadata for application in force.com IDE

I am facing a few problems when trying to integrate the force.com ide with salesforce.com.
Currently i am using eclipse(4.22 Juno) and have installed the plugin Force.com IDE(2.9) and have a developers version in salesforce.com. I was able to successfully connect to salesforce without any errors thru force.com ide, by creating a new application with the name of the application that i have created in the web version.
Right now the application is created with the sub folders classes, triggers etc... but they are empty. I also tried setting the proxy in the connections of eclipse. But even that does not seem to work.
Does anybody have any idea what could be wrong.
Thanks--
Can you post the content of your package.xml file? It's kind of project definition, it contains info which files (objects, classes, pages, reports, profiles...) you want to download & push changes to.
Check http://wiki.developerforce.com/page/An_Introduction_to_Force.com_Metadata for example - have you skipped step similar to this?

Running a Silverlight Application

I have a Silverlight Application (3.0) that I have made changes to in Visual Studio and I can debug the application just fine. My question is what are the steps in getting the application to run through IIS? Visual Studio's project folder for my app is called SilverlightApplication and within that folder it has another SilverlightApplication folder and a folder called SilverlightApplication.Web I assume I copy of of these to C:\Inetpub\wwwroot. Any additional steps?
Many thanks
The first step is to register the MIME types, if not registered already.
The following link contains info on that: http://learn.iis.net/page.aspx/262/configuring-iis-for-silverlight-applications/
The second step is to copy the clientaccesspolicy.xml to the wwwroot, if you have one.
This file is only necessary for cross domain calls, what does not appear to be your case.
After that you can just deploy the app just like any other ASP.NET app.

Resources