How to create standard type Logic Apps using ARM templates - azure

I can create consumption type logic apps with sample workflow using ARM templates. I want to create standard type logic apps with sample workflows using ARM templates.
But, I’m unable to find any reference documentations for the above one.
So, can anyone help me out on this one.

Sorry, in my earlier answer I misunderstood what you were actually asking. Now I believe I got you. But unfortunately what you want to achieve is not possible. And that is by design:
Standard logic apps are fundamentally different to consumption logic apps.
The old logic apps (now called consumption or multi-tenant) make no distinction between the workflow that you execute within a logic app and the logic app as an azure resource. Your logic app really IS your workflow and it runs on an dedicated ISE that you can not configure. That is why you will find all that workflow information in the arm template.
The new logic apps (now called standard or single-tenant) are build upon the same system that function apps are. Now your logic app is an azure resource that provides the runtime for one or more workflows. It is analogous to a function app that can run one or more functions. There is therefore a clear separation between the logic resource that is described in the arm template and the "application code" (your workflow) that is run within this azure resource.
Like function apps you can only create the azure infrastructure resources with arm templates. Azure Resource Manager has no means to deploy application code.
Your workflow definition will be a separate json file to the arm template that defines your logic app infrastructure and the deployment of the workflow is a step that happens after the provisioning of the infrastructure.
See this project for an example of how this can be setup in a CI/CD pipeline: https://github.com/Azure/logicapps/tree/master/azure-devops-sample

To add on Manuel answer, additional useful CI/CD info can be found here - https://learn.microsoft.com/en-us/azure/logic-apps/set-up-devops-deployment-single-tenant-azure-logic-apps?tabs=github
And we had to use different App Service SKU for App Service Plan section. Haven't had time to deep-dive in to SKU Topic, but for us only Workflow Standard (WS1 - for example)plans are available.

If you need to parameterize your connections.json - just refer the values to the appsettings like this:
{
"managedApiConnections": {
"documentdb": {
"api": {
"id": "/subscriptions/#appsetting('WORKFLOWS_SUBSCRIPTION_ID')/providers/Microsoft.Web/locations/norwayeast/managedApis/documentdb"
},
"authentication": {
"type": "ManagedServiceIdentity"
},
"connection": {
"id": "/subscriptions/#appsetting('WORKFLOWS_SUBSCRIPTION_ID')/resourceGroups/INT010/providers/Microsoft.Web/connections/documentdb-test10A"
},
"connectionRuntimeUrl": "#appsetting('connection_runtimeUrl')"
}
}
}

Related

Deploy Azure Blueprint to management group using terraform "azurerm management group template deployment" command

I want to assign an azure blueprint to management group scope.
Since "azurerm_blueprint_assignment" command doesn't support mg level blueprint assignment. Reference : https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/blueprint_assignment
I'm considering to test assigning a blueprint using "azurerm_management_group_template_deployment" command.
As stated here https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_group_template_deployment , terraform supports ARM Template deployment to management scope.
Does anyone tried this method?
If so, I would like to take opinions about whether is it a convenient way of deploying blueprints?
A few highlight as follows;
What could be possible risks and drawbacks?
Is it be possible to provide blueprint parameters individually and retrieve the parameters?
Thanks in advance,

Azure Devops custom extension and current release context

With Azure Devops Services, I need to get azure devops user id which triggered a release, from task.json.
I've got a datasourcebinding with Azure API Management service. This has to get Azure API Management tag based on user id. I've tried different approach :
{
"target": "TEST",
"endpointId": "$(ConnectedServiceName)",
"endpointUrl": "{{endpoint.url}}/subscriptions/{{endpoint.subscriptionId}}/resourceGroups/$(ResourceGroupName)/providers/Microsoft.ApiManagement/service/$(APIM)/products?tags=**$(Release.RequestedForId)**&api-version=2019-12-01",
"resultSelector": "jsonpath:$.value[*]",
"resultTemplate": "{\"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{properties.displayName}}}\" }"
},
I tried also with {{Release.RequestedForId}} but it didn't work.
I saw different resources for datasourcebinding support :
tfs:teamfoundation – Any micro service hosted within TFS (e.g. Build, Test etc.)
tfs:packaging – Packaging service
tfs:feed – Feed service
tfs:rm – Release Management service
tfs:governance - Governance service
tfs:ems - Extension Management service
I found examples for tfs:feed and tfs:teamfoundation only.
Is there any section for users ? Is there any additional information apart from Azure Devops Services REST API ?
Quite few examples in but none for user request.
Is it possible to get current context release variables or azure devops user id directly in task.json ?
This would be a huge help.
Thank you !
You made a small misatke. Instead of Release.RequestedForId please give a try for Release.Deployment.RequestedFor of Release.Deployment.RequestedForId
Docs for Release.Deployment.RequestedFor says:
The display name of the identity that triggered (started) the
deployment currently in progress. Not available in TFS 2015.
Example: Mateo Escobedo
Docs for Release.Deployment.RequestedForId says:
The ID of the identity that triggered (started) the deployment
currently in progress. Not available in TFS 2015.
Example: 2f435d07-769f-4e46-849d-10d1ab9ba6ab
You have this written here.

Runtime whitelist APIM IP on function App using ARM

We are provisioning APIM service first(apim.json), Post which we provision multiple function App.
All the ARM templates are separate with their respective parameter file. We are using Azure Pipelines for CI/CD.
Pipeline1 functionapp1.json
Pipeline2 functionapp2.json
Pipeline3 functionapp3.json
Pipeline4 apim.json
We have an requirement of applying Access restriction on Function Apps. We want to add Access Restriction using ARM templates.
How can we get VIP of APIM on run time so that we can white list VIP of APIM in access restriction section of Function app. All the pipeline are separate for each function app and APIM
Using API and get the value on runtime(Powershell) is one of the option. But we want to handle it using ARM templates.
Any inputs would be highly appreciated.
Used the following to whitelist at runtime.
"ipAddress": "[concat(reference(resourceId('Microsoft.ApiManagement/service', parameters('apimName')),'2019-01-01').publicIPAddresses[0], '/32')]"
See "reference" function for ARM templates: https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-resource#reference

Is there a way trigger "http trigger" azure function, after deploy ARM template?

I have ARM who deploy kubernetes cluster and httptrigger function app. Inside httptrigger func I have client for kubernetes who do some action if I trigger this func manually, its work fine. But I need run this trigger automatically after deploy ARM was finished.
The HTTP request that triggers the Azure Function may be sent either by ARM itself or by whatever orchestrator you use to execute the template (e.g. Azure DevOps pipeline). Terraform can execute scripts directly; unless you really want to use ARM, it might be an option.
If you want to go with ARM, there are at least three options:
Make the Azure Function return an "empty" ARM template and trigger it by a request for a nested deployment template. https://blog.cloudtrooper.net/2017/04/04/run-azure-functions-from-your-quickstart-arm-templates/
Use Azure Container Instances to launch an instance of a container image as a stand-alone container in Azure and execute an arbitrary command inside. https://samcogan.com/run-scripts-in-arm-deployments-with-aci/
Use the deployment scripts resource (Microsoft.Resources/deploymentScripts). It is basically built-in support for the approach using Azure Container Instances. See the official docs or an older article from the time the feature was still in preview that I still like: https://dev.to/omiossec/arm-template-what-s-new-for-2020-4kli#deployementsscripts-resource-provider
In any case, you will need to properly set up the dependsOn references so that the request is sent at the right time. Or better, use Bicep that mostly takes care of the dependencies implicitly, if used right.
Assuming you are using Powershell to deploy your ARM template, you can use Powershell to trigger your azure http trigger function right after you deploy your ARM template:
Invoke-WebRequest -Uri <function_uri> -Method POST
Hope this helps!

Deploy LogicApps from PowerShell

I created in Visual Studio 2017 a new Azure Resource Group and selected Logic Apps. In the project there is Deploy-AzureResourceGroup.ps1.
I want to change parameters in the json file accordingly with the parameters in the LogicApp.json
If I run it, it seems it working but nothing is created in Azure. I change the parameters file
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"logicAppName": {
"value": "LogicApps-Test-Deploy"
},
"logicAppLocation": {
"value": "northeurope"
}
}
}
And nothing happened. I tried to generate in the Azure portal an Automatic Script: in this case I have a script and a template for all my resources (very long and complicate file).
Basically I want to create different scripts for different environment. What is the right process for that?
Don't "create different scripts for different environments". Instead, aim to have a single script ( DeployAzureResourceGroup.ps1 ), a single template to deploy your logic app ( LogicApp.json ), and different versions of your parameters file to parameterize the template. For example,
LogicApp.parameters.dev.json
LogicApp.parameters.test.json
LogicApp.parameters.prod.json
This will enable you to deploy the same infrastructure consistently and reliably, across multiple subscriptions (ie: subscriptions for dev, test, and prod environments).
Also, use a PowerShell console window or PowerShell ISE to test your work. Some of your problem could be simply trying to execute the template in Visual Studio. I've had intermittent issues in the past (mostly token cache issues) executing ARM template deployments from Visual Studio and finally just got in the practice of testing the code from a PowerShell environment, which is what most users of the scripts and templates will be doing anyway.
If you have already created an ARM template for logic app, you can also use Template feature in Azure Portal to fix any issues with your ARM template. I normally use it while developing any new ARM template. This also helps with a detailed error report and in general I find it a better and quick way of identifying any issue.
Have a look the link below -
https://azure.microsoft.com/en-gb/updates/deploy-custom-templates-from-the-preview-portal/

Resources