We have created the Web applications and we have a plan to publish the application as Web App in Azure Marketplace. Publishing the Web App to Marketplace can be done using ARM templates(POC) for one-click deployment for our customers.
When we release the newer version of the application, how can we provide the seamless upgrade to our customers through the Azure Marketplace like Google Play Store (Install button for 1st time and Update button for older version use users?
I came through this article explained the deployment in Azure. But, i didn't find any article for Upgrade Azure App
https://learn.microsoft.com/en-us/azure/app-service-web/web-sites-deploy
We can use git pull command to get the updates from other git repository. In Azure kudu, the command could be like this,
D:\home\site\wwwroot>git remote add gitsource https://username#passwordyourgitserver.com/xx.git
D:\home\site\wwwroot>git pull gitsource master
When we release the newer version of the application, how can we provide the seamless upgrade to our customers
After released the new version of your application, you could force your client to execute upper command to get the updates. If you use C# as your programming language, you could use following steps to execute powershell command.
Install System.Management.Automation dll using NuGet.
Run powershell scripts using following method.
private static string RunScript(string scripts)
{
// create Powershell runspace
Runspace runspace = RunspaceFactory.CreateRunspace();
// open it
runspace.Open();
// create a pipeline and feed it the script text
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(scripts);
pipeline.Commands.Add("Out-String");
//execute the script
Collection<PSObject> results = pipeline.Invoke();
//close the runspace
runspace.Close();
// convert the script result into a single string
StringBuilder stringBuilder = new StringBuilder();
foreach (PSObject obj in results)
{
stringBuilder.AppendLine(obj.ToString());
}
return stringBuilder.ToString();
}
In the ARM template you use to provision the site for the customer, you can enable continuous deployment to that site from a GitHub repo. So anytime that repo is updated, the website (any or all of them) provisioned by your template will be update with the new drop.
See this sample template: https://github.com/Azure/azure-quickstart-templates/tree/master/201-web-app-github-deploy
And then for automated deployments set this to "false":
https://github.com/Azure/azure-quickstart-templates/blob/master/201-web-app-github-deploy/azuredeploy.json#L101
Related
How can I change the appsettings on the preview environemnts that are generated by the Azure Static Web Apps CI/CD Github Action for each pull request?
I can go to the portal, navigate to the generated environment and change its appsettings. Doing this manually for each new pull request is error prone and will become tedious really fast.
I couldn't find any reference to this in the Build Configuration For Azure Static Webapps docs so I'm assuming it can't be configured that way.
I also couldn't find any reference to SWA environments in the CLI docs.
I looked into deployment environments but it looks like this is some other kind of deployment environment as it keeps mentioning devcenter.
In Azure Portal, While Creating Static Web App, after providing the GitHub Repo and Branch details, we will get an option to preview the Workflow file.
I can go to the portal, navigate to the generated environment and change its appsettings
Yes, In Configuration Section we have an option to add the App settings. But it is a manual work, which is not advised to follow.
Once we click on Review + create and create the Static Web App, a new folder with name .github/workflows will be created in the GitHub Repository.
It contains the same workflow file (preview file), which we saw while creating the Static WebApp in Azure Portal.
We can edit the Workflow manually.
To update the appsettings/configurations in the workflow, we can specify the steps in the existing workflow file.
We can use either Powershell/Azure CLI commands to update the Appsettings.
az staticwebapp appsettings set --name YourStaticWebAppname --setting-names "message=HelloEveryOne"
***Sample code for Updating App settings: ***
Before Build and deploystep in Workflow, add the below steps.
- name: Build And Deploy
- run : Your Update appsettings Script
To edit the Workflow file, click on the .github/workflow => .yml file
References taken from MSDoc 1 and 2.
Update
As per the discussion in GitHub, adding appsettings to the preview environment is not currently supported in the default Azure Static Web Apps CI/CD.
Setting appsettings on a specific environment is not currently supported in the Azure Static Web apps CI/CD nor by the Azure CLI.
There is a discussion in GitHub about it.
I am trying to create and use Azure data factory by Rest API but while creation of linked service connection has created successfully but when I checked connection it got failed so is there anything to do test connection by API or PowerShell command.
There is no this method in Microsoft documentation.You can track this feature here.
But there is a blog about testing link service by PowerShell.Here is the script on github.
Hope this can help you.
Now, you can use one of cmdlet in azure.datafactory.tools PowerShell module:
Test connection of Linked Service (preview)
# Example 1
$LinkedServiceName = 'AzureSqlDatabase1'
Test-AdfLinkedService #params -LinkedServiceName $LinkedServiceName
Alternatively, if you prefer, you can run such test as part of your CI/CD process in Azure DevOps installing #adftools extension, which uses the same PS module behind the scenes.
More: https://sqlplayer.net/adftools
Disclaimer: I'm author of the tool.
I'm trying to set up an Azure function that can trigger a Azure devops build pipeline. But I'm not sure on how to proceed with this and if it's even possible to do so.
I already have a build pipeline ready to be used but the conventional triggers that are already provided by Azure devops cannot be used. I can't disclose the reason but I need to trigger it using an Azure function. Any help regarding this would be really helpful.
Thanks.
You can simply use the REST APIs of Azure DevOps and call those from your function. See here: API for automating Azure DevOps Pipelines?
How to proceed with this and if it's even possible to do so.
Of course, it can do to trigger a Azure Devops pipeline by Azure function.
To achieve this, you will use Visual Studio also, better with the version 2017 or higher , and also installed .Net Core SDK and Develop Azure Functions using Visual Studio.
In the Azure Function App you created, open HttpTrigger1, and
click Get Function Url. This is a key point, so better save
it in the txt. Because as this execution, Azure Function just act as
a switching proxy or mechanism.
Create a Azure Function project in Visual studio. In template,
choose HttpTrigger template, Azure Functions v1 (.NET
Framework) from the framework dropdown.
Open .cs file and input the below script in it:
using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;
namespace PartsUnlimited.AzureFunction
{
public static class Function1
{
[FunctionName("HttpTriggerCSharp1")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route =
null)]HttpRequestMessage req, TraceWriter log)
{
var userIdKey = req.GetQueryNameValuePairs().FirstOrDefault(q =>
string.Equals(q.Key, "UserId", StringComparison.OrdinalIgnoreCase));
var userId = string.IsNullOrEmpty(userIdKey.Value) ? int.MaxValue : Convert.ToInt64(userIdKey.Value);
var url = $"https://<<APIAppServiceUrl>>/api/{(userId > 10 ? "v1" : "v2")}/specials/GetSpecialsByUserId?id={userId}";
using (HttpClient httpClient = new HttpClient())
{
return await httpClient.GetAsync(url);
}
}
}
}
Replace <<APIAppServiceUrl>> with your AzureWebsite.net URL.
Go xxxxWebsite->Controllers->StoreController.cs, replace the url
variable in line 46 with your Function url which copied in Step 1.
Click Commit and Push All to push the changes to the Azure
Devops repository.
Create a build pipeline, and enable CI. And also, create release pipeline, add deloy Azure App task and enable CD.
That's all the steps you need to create. There has been a blog which written by our Azure DevOps Labs and it has the detailed steps, you can refer to it.
REST API can be easily invoked from an azure function.
You can pretty much deploy a whole infrastructure as well as deploy the code just based on a function call using azure DevOps.
Refer this for more information: https://learn.microsoft.com/en-us/rest/api/azure/devops/
I'm running web apps as Docker containers in Azure App Service. I'd like to add Datadog agent to each container to, e.g., read the log files in the background and post them to Datadog log management. This is what I have tried:
1) Installing Datadog agent as extension as described in this post. This option does not seem to be available for App Service apps, only on VMs.
2) Using multi-container apps as described in this post. However, we have not found a simple way to integrate this with Azure DevOps release pipelines. I guess it might be possible to create a custom deployment task wrapping Azure CLI commands?
3) Including Datadog agent into our Dockerfiles by following how Datadog Dockerfiles are built. The process seems quite complicated and add lots of extra dependencies to our Dockerfile. We'd also not like to inherit our Dockerfiles from Datadog Dockerfile with FROM datadog/agent.
I'd assume this must be a pretty standard problem for Azure+Datadog users. Any ideas what's the cleanest option?
I doubt the Datadog agent will ever work on App Services web app as you do not have access to the running host, it was designed for VMs.
Have you tried this https://www.datadoghq.com/blog/azure-monitoring-enhancements/ ? They say they support AppServices
I have written a app service extension for sending Datadog APM metrics with .NET core and provided instructions for how to set it up here: https://github.com/payscale/datadog-app-service-extension
Let me know if you have any questions or if this doesn't apply to your situation.
Logs from App Services can also be sent to Blob storage and forwarded from there via an Azure Function. Unlike traces and custom metrics from App Services, this does not require a VM running the agent. Docs and code for the Function are available here:
https://github.com/DataDog/datadog-serverless-functions/tree/master/azure/blobs_logs_monitoring
If you want to use DataDog for logging from Azure Function of App Service you can use Serilog and DataDog Sink to the log files:
services
.AddLogging(loggingBuilder =>
loggingBuilder.AddSerilog(
new LoggerConfiguration()
.WriteTo.DatadogLogs(
apiKey: "REPLACE - DataDog API Key",
host: Environment.MachineName,
source: "REPLACE - Log-Source",
service: GetServiceName(),
configuration: new DatadogConfiguration(),
logLevel: LogEventLevel.Infomation
)
.CreateLogger())
);
Full source code and required NuGet packages are here:
To respond to your comment on wanting custom metrics, this is still possible without the agent at the same location. After installing the nuget package of datadog called statsdclient you can then configure it to send the custom metrics to an agent located elsewhere. Example below:
using StatsdClient;
var dogstatsdConfig = new StatsdConfig
{
StatsdServerName = "127.0.0.1", // Optional if DD_AGENT_HOST environment variable set
StatsdPort = 8125, // Optional; If not present takes the DD_DOGSTATSD_PORT environment variable value, else default is 8125
Prefix = "myTestApp", // Optional; by default no prefix will be prepended
ConstantTags = new string[1] { "myTag:myTestAppje" } // Optional
};
StatsdClient.DogStatsd.Configure(dogstatsdConfig);
StatsdClient.DogStatsd.Increment("fakeVisitorCountByTwo", 2); //Custom metric itself
I have an ARM template that I use to deploy a DocumentDB as well as other Azure reosurces to a resource group. I want my ARM template to setup a Stream Analytics job that uses the DocumentDB as output. In order to do this the DocumentDB account created by the ARM template needs to have a database and a collection setup as well. I cannot find a way to do this from an ARM template so I have written a Powershell CmdLet to create the database and collction for me.
The Stream Analytics job cannot be created by the first ARM template since it depends on having the database and collection created first. Instead I have to divide the deployment into two ARM templates, the first setting up the DocDb account and the second setting up the SA job.
The problem is that I cannot create a database in the DocDB account directly after having deployed the account via the ARM template. I get an exception with the following message: "The remote name could not be resolved: 'test.documents.azure.com'" when I try to execute the CreateDatabaseAsync method with the DocDbEndpoint and AuthKey I get back from the ARM template deployment.
Are there any timing issues after having deployed Azure resources using a ARM template before you can access them programatically? This do not seem to be a problem with other Azure reosurces created this way.
Any help on this matter is highly appreciated as well as what is a good practice for working with ARM templates with DocumentDB and Stream Analytic jobs.
Update 2016-03-23
Code for setting up the connection to the DocumentDB to create the database.
Uri endpointUri = new Uri(documentDbEndPoint);
DocumentClient client = new DocumentClient(endpointUri, authKey);
var db = await client.CreateDatabaseAsync(new Database { Id = databaseId });
return db;
Where the documentDbEndPoint is in the form of: https://name.documents.azure.com:443/ and name is the name of my DocDB account just created by the ARM template deployment.
I have the code in a library which I can either call from a Console application or from a Powershell script by loading the library with:
Add-Type -Path <path to library dll file>
No matter if I use powershell or console application I get the same error if I try to create a database just after having created the DocDB account using the ARM template. If I wait like an hour or so both the powershell script and console application works and can create a database in the account.
Seems like there is some kind of timing issue in order for Azure to setup dns records for the newly created DocDB account so that it can be accessed using the DocDB API.
Update 2 2016-03-23
Just tried to create a DocDB account directly from the portal and doing this instead of creating it from an ARM template makes it possible to create a database in the account using my powershell script and console application immediately.
This timing issue has been fixed now and you should be able to use it from the ARM template now.