update source code of react through azure pipeline - reactjs

I have created a react environment variable in .env file and is able to update it through command prompt or power shell now my aim is to update it through azure pipeline so add a powershell script.But I am not able to figure out how to read or write data in .env file through a azure pipeline powershell script. I wish to change base url for differnet envirnoments dev stage prod (base_url_dev = https://projectName.dev.azurewebsites.net/). Please let me know If there is any other way

You would commit your file like this:
base_url = '#{base_url}#' (never commit enivornment specific values into Source Code)
And then set a base_url variable in each AzDo Stage to the actual value. (You can also use stage scoped variable groups)
in each stage, use a replacetokens step and target your .env file to replace the #{base_url}# to the actual value you declared for each stage.

update source code of react through azure pipeline
We could remove the base url from the .env file, then use a Inline powershell task to set the base url via Logging Command:
Write-Host "##vso[task.setvariable variable=REACT_BASE_URL;]$(REACT_BASE_URL)"
Then define the variable REACT_BASE_URL with different value for different stages in the Variables tab:
Alternatively, just like michiel said, we could use the task Replace Tokens to update the value in the .env file.
Change the base_urls values to #{REACT_BASE_URL}#`:
REACT_BASE_URL = #{REACT_BASE_URL}#
Then, also defined the variable REACT_BASE_URL with different value for different stages in the Variables tab.
And add the task Replace Tokens in the pipeline:

Related

How to use switch functions to check if the file name conatins ABC

I have created a logic app where I need to check if my file name contains "ABC" then i need to copy file and paste it in ABC folder Azure else need to check if my file name contains "ZYX" then paste it in ZYX folder in Azure.
In switch function its giving me an error.
"The execution of template action 'Switch' failed: The result of the evaluation of 'scope' action expression '#body('Get_file_content')' is not valid. It is of type 'Object' but is expected to be a value of type 'String, Integer'." [Image1]
or if I am trying to use 2 conditions in parallel branch its giving me the below error.
![Image2]
I also tried conditions, if the file name contains "ABC" then copy paste in ABC folder if false then i tried using another conditions inside the false command.
Also, follow up question would be if I have multiple file name with ABC then can I merge and place it in one file and paste that in ABC folder in Azure Blob
Image using switch function:
Image Conditions using parallel branch:
![Image Conditions using parallel branch]
Attaching the latest screenshot with your suggestion.
enter image description here
i just tried using one and its giving me the error.
enter image description here
Reason for the error : You cannot passfile content as a condition check in the switch Connector.
Solution: In order to get the desired output as described above you need to pass the file name as a condition check in switch control. As we receive the File Name from the SharePoint connector as base64 format we need to decode it to string using **base64ToString(FileName)** to compare the folder names present in the containers/blob.
Here is the code view of the logic app based on the above-discussed requirement.
Also, follow up question would be if I have multiple file name with
ABC then can I merge and place it in one file and paste that in ABC
folder in Azure Blob
Using the above flow, merging of files is not possible since each file is saved in different extensions but override of the file takes place in the blob if you are uploading or updating the same file.
For more information about merging of files using Logic app you can refer this BLOG.
UPDATED ANSWER
Before Comparing the string/ Filename you can use 'Compose' before the 'Condition' Connector and convert the string into lower case.
toLower(base64ToString(triggerOutputs()['headers']['x-ms-file-name-encoded']))

Store XML retrieved value as string variable for use in child package

I would like to store an XML retrieved value as a string variable for later use in a child package within SSIS. The situation is as follows:
I'm retrieving an ID from an XML file in a data flow task (A). I need to save this ID as a variable so I can pass it later on to a child package via package configurations and use it there. The issue is that with the 'Recordset Destination', I can only store it as an object type, and then I can't seem to convert it in my child package to a string again.
I think that I can solve this with a foreach loop, but I don't feel like this is very performant. Is there any other way to do this? I attached some screenshots to make the situation a bit more clear.
Thanks!
Screenshots
You can use a Script Component to Store the ID value in a variable, Just add the script component as destination, select the variable as Read\Write variable in the script form. And assign a value to this variable in the PostExecute() function inside the Script Editor.
You can refer to one of the following link for more information:
How to use variables in a Script Component
Using Variables in the Script Component
Read and Write variables in a Script Component in SSIS (SQL Server Integration Services) using C#

Passing variable in XML topology in ODI

I am trying to parameterized the topology connection in ODI to load multiple xml of same structure one by one using variable.But i am getting unknown token error.
Jdbc url :jdbc:snps:xml?f=U:/SOTI_CLOUD/#B.xml
{ #B is ODI variable having file name)
Try using #GLOBAL.B if it is a Global variable or #<PROJECT_NAME>.B if it is a project variable.
Also check what is your history setting for that variable. If it is set on "No History", make sure you are declaring/refreshing the variable within the same session in which you want to access that XML file.
Just a hunch…
For the variable to be picked up in JDBC URL you need to launch a separate scenario. Your problem might be different but make sure you have an outer loop with variable declare/refresh and whenever you refresh/increment it you launch a separate scenario (not just an interface) where you load data using such constructed URL.

can we drop a file to a folder location automatically using camel,or at a set period of time(not intervals)?

Iam trying to automate the testing of a java bundle,Which will process once a file is dropped in a particular folder.
can we drop a file to a folder location automatically using camel,or at a set period of time(not intervals)?
is this possible purely by camel or should we incorporate other frameworks?
sure, you can use the camel-file component to produce (create files somewhere) and consume (read/process files from somewhere) and optionally control the initial/polling delays easily with attributes...
here is a simple example of consuming->processing->producing
from("file://inputdir").process(<dosomething>).to("file://outputdir")
alternatively, you could periodically produce a file and drop it somewhere
from("timer://foo?fixedRate=true&period=60000").process(<createFileContent>").to("file://inputdir");
Although camel could do this by creating a timer endpoint, then setting the file content and writing to a file endpoint, my answer would be to simply use a bash script. No camel needed here.
Pseudo bash script:
while [ true ]
do
cp filefrom fileto
pauze 10s
done

Foreach Loop Container failed to traverse through all files in a folder

I have one temp folder C:\Mydata inside that i have .csv files with name
demo1.csv demo2.csv...etc
Now I want to insert data from all those files into database table
for this I have taken Foreach Loop Container in the property Directory I mention
C:\Mydata
inside Foreach Loop Container taken a Data Flow Task in that Flat File Source is there in the connection manager property in file name what should I mention, so that it will traverse through all folder and all files whose extension is .csv
I did like C:\DEMO\*.csv which is giving me error :
no file found path is wrong
From what i interpreted, your issue was assigning the resulting file from the foreach to the connector.
To do that you need to assign the filename from the Foreach to a variable.
The first step to be taken is to create the variable. To do that you need to activate the "Variables" window:
Then you need to create a new variable of type string and rename it.
For more information on SSIS variables and how to create them, see http://msdn.microsoft.com/en-us/library/ms140216.aspx
Now you need to assign the new variable (in this case i named it "filename") to the foreach loop:
NOTE THAT WHILE THE OPTION "Name Only" IS SELECTED IN THE FIRST WINDOW, IN YOUR CASE YOU PROBABLY WANT "Fully Qualified"!!
The screenshot was taken from a working project i have and i am using only the name (Name Only) as opposed to the full path (Fully Qualified)
After doing that you need to assign that variable to your flat file connector using expressions:
Which version of MSSQL and SSIS are you using? And why are you using C:\Mydata in one place and C:\DEMO in another?
The basic technique of looping over files is described here.
There is lot of information about these steps in the documentation and on the web. If you need more help, please be as specific as possible about what you've tried, what isn't working, what versions you're working with etc.

Resources