Setting Environment Variables using IIS Administration API - rest

Does anyone know how to set environment variables on an application pool using the IIS Administration REST API?
https://learn.microsoft.com/en-us/iis-administration/api/application-pools

Setting environment variables using the Web API isn't currently possible.
If anyone else is interested in this feature, i've created a branch containing a first draft. Maybe i will submit a PR after some testing.
My Branch
You can then create an AppPool like this:
{
"name": "Demonstration App Pool",
"environment_variables": {
"CONNECTION_STRING": "some value"
}
}

Related

How to pass all global credentials to Jenkins pipeline

This is my first question posted on stackoverflow, hence in case I did something incorrectly pleaselet me know.
Description
I am currently working on translation of freestyle projects to declarative pipelines in Jenkins (jenkinsfiles kept in Git repo). The original freestyle job was triggering PowerShell script which needed access to Global name/password pairs defined in Mask Passwords plugin section in Configure System. Solution to this problem was an additional tick in project itself (unfortunately I am not allowed adding screenshots to posts yet, hence editor uploaded screen to imgur and pasted link - please see Screenshot 1):
Screenshot 1
Therefore I started looking for possible implementation of such solution to jenkinsfile, however wothout luck.
My problem
When the script is triggered from the pipeline, it errors out stating that it cannot find relevant passwords (powershell refers to those credentials as to environment variables). This works fine when ran from freestyle project.
Which I reckon is caused by pipeline not being able to reach out to previously mentioned credentials.
What I tried
Wrapping the step into below block:
wrap([$class: 'MaskPasswordsBuildWrapper']) {
bat(batch file launching ps script)
}
Then the above block containing relevant step wrapping into
script {
wrap(...)
}
But none of them worked.
I have taken a look at other plugins like Credentials Binding Plugin or Credentials Plugin but those allow to bind/pass one credential per step, and I need to pass all credentials specified in Jenkins (I am open to move saved credentials to any other location within Jenkins).
I have looked at adding environment variable:
credentials('Credentials-ID')
But the problem is the same as with mentioned plugins.
By any chance, have anyone came across similar situation and know what can be done in order to allow pipeline to access/pass to pipeline all the credentials specified in Jenkins instead of binding/passing them one a time?
All tips are very welcome!
You can do this and the env variable will then be available throughout your job. You could define multiple env variable too.
environment {
// Use credentials() to hide the environment variable's output
MY_PERSONAL_TOKEN = credentials('Credentials-ID')
}
stages {
stage('Test Stage') {
steps {
script {
// do what you need to
}
}
}
}

Configuration Management in AKS Deployment with Azure Pipelines for Different Environments

I have created a ASP.NET Core WebAPI and deployed in an Dev Environment (Kubernetes) using Azure Pipelines. How can I update the configuration in the pipeline if I need to publish the same API in another environment (eg. SIT). Since I have different settings/configuration for Dev and SIT environments.
Kindly guide me.
You can use release variables to do this. Feel free to reachout if you need any assistance.
https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch
https://learn.microsoft.com/en-us/azure/devops/pipelines/release/?view=azure-devops#how-do-i-specify-variables-i-want-to-edit-when-a-release-is-created
The problem occurs when I want to deploy the same API to other
environments like QA/UAT/Prod. Since each environment is having
separate databases
For this issue , there are several ways to achieve this. You can add Replace Tokens extension to the job to replace the database connection string in appsettings.json.
You can define your variable like below:
{
"ConnectionStrings": {
"DefaultConnection": "#{connectstring}#"
}
}
You can refer to this case and lab for details.
Here are some reference for the same issue:
Replacing database connection strings in the Docker image
Set Json Property task to replace the ConnectionStrings

Azure webapp and and their webjobs deployment

I want to deploy webapp and their webjobs in environments using VSTS ci/cd.
Note:
1.The webapp having three webjobs( WJ1+ (WJ2+Its instance(2))
2.The webapp having 6 webjobs( WJ1+ (WJ2+Its instance(5)).
3.its not picking the variables which we aren't adding in release pipeline.
Quick help much appreciated
Thanks,
SP
Web Jobs will not pick the variables from your release pipeline, instead it can get these variables/settings from the web app's appsettings section.
You can do that manually by setting the appsettings for the web app in Azure Portal by following this link https://learn.microsoft.com/en-us/azure/app-service/web-sites-configure
Or you can do it automatically by changing web.config/appsettings using transformation tasks in your release pipeline as instructed in this link
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/transforms-variable-substitution?view=azure-devops
As for the web jobs deployment:
If you added the web jobs from visual studio, it will add a file under the properties folder in your web app called webjobs-list.json. If it is not there, then add it and the content should be similar to:
{
"$schema": "http://schemastore.org/schemas/json/webjobs-list.json",
"WebJobs": [
{
"filePath": "../webjob1.csproj"
},
{
"filePath": "../webjob2.csproj"
},
{
"filePath": "../webjob3.csproj"
}
]
}

Heroku Review Apps not deploying at all

I'm trying to automatically create review apps as part of my pipeline and testing procedure when pull requests are created on the corresponding GitHub repository. When the PR is created, it appears as a review app, but doesn't actually get created.
In the DevTools console, a 404 error is there about the review-app-config. I'm not sure if this is directly related, as I've successfully created a review app on a different pipeline (with a different owner) with the same error.
This 404 error changes between the file not being available at all, or that it's returning an error. When it's the latter, the file contains the following:
{"id":"missing_version","error":"Please specify a version along with Heroku's API MIME type. For example, `Accept: application/vnd.heroku+json; version=3`.\n"}
I'm creating and managing all of the apps/pipelines with the GUI on dashboard.heroku.com. The version accept header appears to be needed for the Heroku API but I've no idea how to implement it. Any help would be greatly appreciated!
Firstly check that your app.json file is valid json. If it isn't then that will cause the deployment to fall over.
Secondly check if you have any scripts in the app.json key. If you have any here and they are incorrect then this will also cause it to hand and fall over with no warning displayed.
{
"name": "App name",
"scripts": {
"deploy": "command that won't work!!"
},
...
}
You many not need any scripts in here so it can also be empty!
{
"name": "App name",
"scripts": {},
...
}

VSTS Web Hooks get silently disabled?

VSTS,
How does one configure VSTS to never auto-disable ServiceHooks that encounter errors? Looking thru the UI, there's no checkbox for 'always run, regardless of errors'.
Occasionally, we have to take-down the receiving service for maintenance, we need VSTS to continue to send the request regardless of any errors encountered (past or present).
No, there isn’t the way to configure it to never auto disable service hooks that encounter errors.
Also, continue to send the request regardless of any errors encountered (past or present) will affect the performance.
You can build a app (e.g. windows service) to check and enable web hooks through REST API: Update a subscription.
For example:
Put https://[account].visualstudio.com/_apis/hooks/subscriptions/[subscription id]?api-version=1.0
Body (Content-Type:application/json)
{
"publisherId": "tfs",
"eventType": "build.complete",
"resourceVersion": "1.0-preview.1",
"consumerId": "webHooks",
"consumerActionId": "httpRequest",
"scope":1,
"status":0,
"publisherInputs": {
"buildStatus": "",
"definitionName":"ClassTestVNext",
"projectId": "578ca584-4268-4ba2-b579-7aaee499c306"
},
"consumerInputs":{"url":"http://XXXX/"}
}