Run acceptance/smoke tests after deployment - asp.net

I have set up continuous deployment from a Visual Studio Online Git repository to an Azure Web App.
What is the best way to run acceptance/smoke tests on the website after a build is triggered and deployment has completed?
I have already tried POST_DEPLOYMENT_ACTION (How to add a custom post deployment script to azure websites?), but this seems to get ignored.
I also had a look at the Kudu PostDeployment hook (https://github.com/projectkudu/kudu/wiki/Post-Deployment-Action-Hooks), which appears overly hacky.
I am deploying a standard ASP.NET 4 MVC site by the way. Any help appreciated.

What is hacky about the PostDeployment hook?
An alternative to that could be to subscribe to the PostDeployment hook from the Kudu/SCM site
POST /api/hooks
{
"url": "http://www.callback.com/callback",
"event": "PostDeployment",
"insecure_ssl": false (set to true to ignore https certificate check, for test purposes only)
}
That would give you a POST like below on the specified URL when deployment is done:
{
"id": "cd5bee7181e74ea38a3522e73253f6ebb8ed72fb",
"status": "success", (could be pending, building, deploying, failed, success)
"author_email": "someone#somewhere.com",
"author": "Some One",
"message": "My fix",
"deployer": "Some One",
"start_time": "2013-06-06T01:24:16.5873293Z",
"end_time": "2013-06-06T01:24:17.63342Z"
}
More info here on kudu github wiki

What I ended up doing was customizing the build process to add a RunScriptTask at the end, which invokes my tests.
You can pass build parameters to the RunScriptTask like so:
"-username user#example.org -password test123 -environment " + DeploymentSettings.GetValue(Of String)("ProviderHostedDeploymentEnvironmentName")
If you edit the build definition from Visual Studio -> Team Explorer -> Builds, there is a tab on the left called Process that breaks down the build steps. If you click Show details at the top, there is an option to download the XAML build process template. You can customize this as you wish and then create a new build process template from that file. (Note that XAML build process template file must be pushed to the remote repository beforehand)

Related

In azure functions 3 can I filter logs to application insights and the console at different levels

I'm developing azure functions using visual studio and the v3 runtime.
I'm trying to reduce the volume of trace messages going to application insights but I would still like to see them when running the function locally in visual studio.
From reading bits of documentation I think I need to set up log filtering at "Information" for the application insights provider and "Trace" for the console provider.
Is this possible? I've been trying out changing the hosts.json file from settings that I've found online but the filters only seem to apply to the log category, not the provider.
Is this possible?
You can override settings in your hosts.json file by creating an application setting. As per the docs, you just need a setting with a name like AzureFunctionsJobHost__path__to__setting. For example:
{
"IsEncrypted": false,
"Values": {
/* snip */
"AzureFunctionsJobHost__logging__logLevel__default": "Trace"
}
}
And in your function app, just add AzureFunctionsJobHost__logging__logLevel__default with a value of Information.

Flutter: I am getting an outdated message when trying to launch

Hey can someone help me I followed a tutorial from about 2 years ago to make a login/auth page that links with firebase. I tried to run the app at the end and it opens launch.json and asks for a configuration. Here is the code it wants me to add a config to.
"version": "0.2.0", "configurations": [
{
"name": "Flutter",
"request": "launch",
"type": "dart"
}
]
}
Here is the link to the tutorial github. Is there any way I can fix it to run now? https://github.com/tattwei46/flutter_login_demo
launch.json is a VSCode file that stores different build methods for your workspace. It's not really related to your flutter project setup. Allow VSCode to add the config to the file and it should work fine. If launching using VSCode shortcuts is not necessary, you can just do flutter run.
You can read more about this file here. This doc uses a different language as an example, however, this doesn't matter as the file is for VSCode, not flutter/dart.
I recommend you to create new flutter project then copy flutter_login_demo lib into the new flutter project lib with pakages in yaml and images if icluded. its better becuase you may get extra errors like android X error .

How to replace json config values before Xamarin iOS and Android build task in pipeline

I'm working on a Xamarin.Forms app for both iOS and Android, in the shared project I have an appsettings.json file where I'm placing some base settings keys/values.
Those key's values I want to be replaced depending on config variables I have in the .YML file inside my build pipelines, so for instance the key { "url": "" } for Debug Pipeline will be { "url": "http://google.com" } and for Release Pipeline will be { "url": "http://amazon.com" }.
I've handled this scenario previously in .NET Core projects but I've no idea how to do it with Xamarin, I know there is a File Transform task in the Azure Pipeline pre defined tasks, but it requires a .zip package or folder path to find the .json and transform it, but for mobile apps I think there is no suck thing like a pre-build folder.
I request your assistance.
How to replace json config values before Xamarin iOS and Android build task in pipeline
If you have different pipelines for the different config variables. You could just use the task Replace Tokens to update the key's value of the url in the appsettings.json file directly.
You could check my previous thread for the details.
Besides, if you are using one pipeline for the different config variables, we need use the Logging Command and REST API (Definitions - Update) to update the value of the build definition variable from a build task.
Add a Inline powershell task with following Logging Command to set the variable URL:
$config= $Env:configuration
Write-Host "Current config is $config"
if ($config -eq "Debug")
{
Write-Host ("##vso[task.setvariable variable=URL]http://google.com")
}
elseif ($config -eq "release")
{
Write-Host ("##vso[task.setvariable variable=URL]http://amazon.com")
}
Use REST API (Definitions - Update) to update the value of the build definition variable with the value URL.
Use the task Replace Tokens to update the key's value of the url in the appsettings.json file
Hope this helps.

Using Gulp to publish ASP.NET application

I would like to use a gulp task to compile and publish my ASP.NET application and integrate it in my overall release. I tried to find something via google and on StackOverflow, but I was not successful. Visual Studio (2015) is also not very helpful, as it does not show which commands it uses (if this is not an internal process).
I would like to get the same output as selecting my project -> Publish... (see image)
Is this possible somehow? Has anybody automated this or do I have to use the TFS build system to do it? Or does somebody know if I can use VisualStudio on my command line to automate the process?
EDIT:
It is currently an asp.net 4.5.1 application.
I found a solution, thanks to whoever voted for this question, I forgot about it.
Here is my example:
gulp.task("publishaspdotnet", (done: DoneCallback) => {
const gatewayBuildSolutionName = "My.sln"; // maybe also .csproj possible
exec("msbuild " + gatewayBuildSolutionName + " /p:DeployOnBuild=true /p:PublishProfile=localrelative /p:Configuration=Release /p:Platform=\"" + target + "\"", logConsoleOutput).on("exit", () => {
gutil.log("Really done --------------------------------------");
done();
});
});
});
Here are the steps:
Create a publish profile for your ASP.NET project (right click on your project -> publish...)
You can edit the profile, just click on "show all folders" in your solution explorer, go to publish profiles and edit your profile to deploy relative to the .csproj file which the pubxml file belongs to. The publishUrl tag is the place your code gets published to (if you set to local)
Write your gulp task and use msbuild to build. Use the switches as shown in the example above and reference your publish profile there. Now publish will be executed

How to deploy to Azure Resource Group using VSTS release management

I am new to Visual Studio Team Services Release Management. My goal is to automate a deployment of an ASP.NET MVC application to the Azure App Service.
Trying different approaches, I created a Service Endpoint that is certificate based and one that uses a service principal (SPN). My build definition already builds a web deploy package, and the release definition is linked against that and can use this artifact.
Success 1:
A deployment of the app using the Azure Web App Deployment Task already succeeded - almost.
Shortcoming 1: I do not understand how I can specify the correct Resource Group using this task. This uses the certificate based endpoint, and for this task I cannot use the other (SPN) endpoint.
Success 2:
Using the Azure Resource Group Deployment task, I was able to use a JSON ARM template to create a new resource group with a web app in it. This way I can specify the resource group, addressing Shortcoming 1
Shortcoming 2: But now I don't understand how I can actually deploy the binaries of the build definition that has been linked against my release definition. The web application that gets created by the resource group deployment is empty, and a subsequent Web App Deployment Task seemingly cannot target this newly created web app, since it is probably not ARM based.
I get the feeling that I am missing something obvious here - any help is appreciated.
Update 1
Thanks to #bmoore-msft, I got a deployment working using the child resource extension example he linked to. Essentially, the corresponding snippet of my ARM template now looks like this:
"resources": [
{
"apiVersion": "2015-08-01",
"type": "Microsoft.Web/sites",
"name": "[variables('fullEnvName')]",
"location": "[parameters('siteLocation')]",
"properties": {
"name": "[variables('fullEnvName')]"
},
"resources": [
{
"apiVersion": "2014-06-01",
"name": "MSDeploy",
"type": "Extensions",
"dependsOn": [
"[concat('Microsoft.Web/Sites/', variables('fullEnvName'))]"
],
"properties": {
"packageUri": "https://dl.dropboxusercontent.com/u/<myId>/<WebDeploymentPackage>.zip",
"dbType": "None",
"connectionString": "",
"mode": "Complete"
}
}
]
}
]
But the problem is that this places a static link into my template - as you can see, I used Dropbox as temporary solution. But of course I don't want to upload my web deployment package to Dropbox, neither manually nor automatically. I want to link to the artifact created by my build definition, which unfortunately is dynamic and I can't find any information on how to construct this link. For example, build 1 is located at the following path
https://<tenant>.visualstudio.com/DefaultCollection/_apis/resources/Containers/800850?itemPath=<PathToWebDeploymentPackage>.zip
while build 2 is available here
https://<tenant>.visualstudio.com/DefaultCollection/_apis/resources/Containers/801968?itemPath=<PathToWebDeploymentPackage>.zip
So there is a number changing inside the link which means the link I refer to in my template must be dynamic which means I need to understand where to get that number from, which I don't.
Maybe there is another way of referencing artifact uploads?
Take a look at this sample:
https://github.com/Azure/azure-quickstart-templates/blob/75d0588fbd2702288bd35ed24cb00e43dcf980c2/wordpress-mysql-replication/website.json
The website in that template resource has a child resource extension named "MSDeploy". This will deploy a package to the web site during deployment. So in your task that does the deployment you can create the web app, and deploy the package all in the one deployment task in RM.
You will need to use user or SPN authn for anything using ARM (no certs).
Update: Staging the Package
Ok, usually what I do here is "stage" my artifacts in Azure Storage (secured with a sasToken). The uri you provide in the template must be accessible to AzureRM. You VSTS build output is likely secured, so even though you could access it interactively, AzureRM cannot.
Essentially what you need is a task in RM (or build) that will 1) copy the artifacts to Azure (securely) and then 2) tell the next task where those artifacts are... Here's one option:
https://azure.microsoft.com/en-us/documentation/articles/vs-azure-tools-resource-groups-ci-in-vsts/
This doc is using VSTS build, but RM works the same way. The other part that's different is the doc is using a PS script used by Visual Studio in the Azure Resource Group projects. There's nothing special about that script (it will work anywhere just like any other PS script) but that's the example. It doesn't use the Azure Resource Group Deployment Task because that task cannot do the staging of the artifacts.
Essentially what you need to do is:
parameterize that URI property (see example & repo below)
copy the webdeploy package to Azure (PowerShell in this case)
deploy the template and pass in the uri of the package
e.g.
"packageUri": "[concat(parameters('artifactsLocation'), webdeploy.zip, parameters('sasToken')]"
That doc shows you how VS does it, and you should be able to adapt that for your scenario. If you go this route, you would use the Azure PowerShell task and no longer need the Azure Resource Group Deployment Task.
Another way to do this is with the Azure File Copy task, but currently that task does not output the URI or sasToken, so you couldn't pass it in to the deployment task (there's a PR in the queue to make that work).
Another option if you don't have access to Visual Studio is this repo:
https://github.com/Azure/azure-xplat-arm-tooling/tree/master/PowerShell
It has the same PS script that VS uses, and the templates show an example of the parameterized URL (for a dsc.zip file in this example) but would work the same way for msdeploy.
You've actually hit on one of the more sophisticated scenarios and at the moment not doc'd real well, but it's pretty cool when it works. LMK if you need more help here.

Resources