Multi site Azure gateway - terraform

How to create single azure application gateway for multisites. Both applications are under different resource groups and VNET.
Need single application gateway for test.example.com and test1.example.com.

• Since you have included the tag of ‘terraform’ in your question, I am assuming that you want to create an application gateway for your purpose using the terraform IAC. Thus, you can surely create an application gateway for multiple sites across different tenants/subscriptions and across different virtual networks if the app services hosted are reachable over the internet, have IP connectivity and are accessible. Kindly refer to the official Microsoft documentation link below for your query regarding communication outside instances of the application gateway’s virtual network: -
https://learn.microsoft.com/en-us/azure/application-gateway/application-gateway-faq#can-application-gateway-communicate-with-instances-outside-of-its-virtual-network-or-outside-of-its-subscription
Thus, to create an application gateway as required by you through terraform, kindly follow the steps as below: -
a) Install the ‘Azure Terraform’ extension in Visual Studio code as given in the below documentation: -
https://learn.microsoft.com/en-us/azure/developer/terraform/configure-vs-code-extension-for-terraform?tabs=azure-cli
b) Once done as stated in the above documentation link, then edit the ‘main.tf’ file with the code given in the below link and modify the ‘variables.tf’ file with the required values of the parameters related to the application gateway deployment in Azure: -
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/application_gateway
c) Once the above has been done, initialize the terraform with the code ‘terraform init’, then create the execution plan with the command ‘terraform plan -out main.tfplan’
d) Then apply the terraform code specified in the above plan with the command ‘terraform apply main.tfplan’
Thus, in this way, the application gateway will be deployed using terraform IAC.

Related

Azure release pipeline keeps adding ".scm" to the appservice's URL

I have an appservice called compspiadev, and I am using Azure's Pipelines to set-up CI/CD. Created the build pipeline and build the project into an artifact to use it in the build pipeline. When I try to deploy I get the following error:
Now my appService doesn't have the ".scm." part in it, and in my configuration I don't set the name to have the KUDU endpoint it adds it automatically:
How can I fix this issue for it to deploy correctly?
Your guess is correct. That is an network error which is because our Azure devops Hosted agent could not connect to the internal deployment endpoint of ILB ASE. (As I mentioned in this ticket, I checked your app from our backend and found it is connecting to ILB ASE.)
You can check this source code (actual working code snippet, I can not help you locate the exact code line since I don't know witch deploy method you used), and you will found that the process of Azure app deployment via Azure app service deploy task is actually the process of communicate with app files to Kudu service (xxx.scm.azurewebsite.net).
For example, if you are using Run from package type to deploy your web app, you can refer to this code snippet.
After you configured ILB ASE, per this doc, the scm site is only available at <appname>.scm.<asename>.appserviceenvironment.net. But you should have known that Hosted agent is a dynamic-distribution Azure VM that is neither in nor connected to the virtual network.
That is why you encountered the error like could not connect to the remote computer <appname>.scm.<asename>.appserviceenvironment.net.
To resolve this issue, you need use private agent to execute your deployment pipeline. For how to configure a valid self agent so that it can communicate with your private DNS, you can follow this reply or this blog.
As is visible in (the URL part of) the error message in your first image, you're deploying to an App Service Environment (which is something of a special cookie).
The Azure App Service Environment is an Azure App Service feature that provides a fully isolated and dedicated environment for securely running App Service apps at high scale.
As we can see in the second image, you don't have the checkbox "Deploy to Slot or App Service Environment" checked.
Check that checkbox, specify the Resource Group name, leave slot name set to production and you should be good to go.
If the deployment target is an Azure App Service environment, leave the slot name as production and specify just the Resource Group name.
Source: Azure App Service Deploy task - Prerequisites for the task

How set up VNet integration and Access Restriction for Azure WebApp from ansible

Pls help !
I need create some web app from ansible, and add this web app to an existing VNet.
For create WebApp i use ansible module - azure_rm_webapp, and all work fine but i can`t find any way configuring network for created web app.
Can i do it from ansible?
How can i do this ?
I read about ansible module for creating network (may be there i can add , but also not find )
I am afraid that we can not do VNet integration using ansible module. Here are all modules for Azure by using ansible and ansible-playbooks samples.
In this case, you may consider using some shell, script, or win_shell modules to execute some commands on target hosts after the VM provision. Here is an arm template for deploying a web app with VNet integration.
If you consider other automatic deployment tools. I would like to recommend the terraform tool. it supports resource azurerm_app_service_virtual_network_swift_connection which makes you manage an App Service Virtual Network Association. Also, you can use ip_restriction block and scm_ip_restriction block under the resource azurerm_app_service to configure Access restriction.

Azure DevOps release pipeline with Azure Application Gateway and Virtual Machines

My target is to create Azure Resources from Azure DevOps release pipeline. Resources that are created are virtual machines and application gateway (+ all the necessary vnet's etc.). Resources are created successfully, but the pipeline wont work through application gateway. Currently the pipeline has "Azure File Copy" -task to copy some scripts to the virtual machines. This setup works without application gateway but I cannot get it to work with application gateway.
Error message I get from Azure DevOps is: "Unable to get FQDN for all resources in ResourceGroup"
I have created a ticket to MS but they were not able to resolve this issue ("Works as expected") yet and now waiting for Azure DevOps support to participate, but since it is a bit slow I decided to post a question about this here since I think that someone might have bumped into this before as well.
Does anyone have idea if this setup is supported or have any workarounds? Main need would be to copy and execute scripts in virtual machines.
Talked with Azure Networking team and Azure DevOps team and there is no way around this at the moment. Virtual machine must have public IP address to use "Azure File Copy" -task.
So I ended up adding additional NIC with public IP address to the VM and use NSG to only allow traffic from Azure DevOps pipeline.
EDIT: Created a feedback item, please vote if you need this functionality as well: https://feedback.azure.com/forums/217313-networking/suggestions/36482038-add-application-gateway-support-for-azure-devops-t

Extra Resources Created In Azure For VM

When I create a VM in Azure, it is creating an accompanying Cloud Service and Network Resource. I found that the Cloud Service is there as a deployment layer. I have not found why the Network Interface is there.
Since this particular circumstance is not going to have a deployment associated with it as it is used as an Elasticsearch server, I technically will not be needing the Cloud Service. However, when I delete the service, it takes the VM with it even though I do not expressly select it for delete.
My two specific questions:
1st - Why is there a Cloud Service created and not able to be deleted without repercussions when there is not deployment necessary?
2nd - Why is the Network Interface created and not able to be deleted without repercussions?
Both questions are with the understanding that this is an Elasticsearch VM.
A cloud service is a required artefact of an ASM/classic deployment if a VM. It is not needed in an Azure Resource Manager deployment, which is what you should use for new deployments. However, the two types of deployment are orthogonal, so you may need to keep using ASM if you already have VMs deployed that way. If so, you should consider migrating them to ARM.

Azure Cloud Service Deployment

I am having an issue deploying to the Staging environment of my Windows Azure Cloud Service.
This is something I do frequently without issue before doing a swap to Production (once I have validated everything is OK in Staging). Today for some reason I am getting this error when trying to deploy:
Allocation failed; unable to satisfy constraints in request. The requested new service deployment is bound to an Affinity Group, or it targets a Virtual Network, or there is an existing deployment under this hosted service. Any of these conditions constrains the new deployment to specific Azure resources. Please retry later or try reducing the VM size or number of role instances. Alternatively, if possible, remove the aforementioned constraints or try deploying to a different region. The long running operation tracking ID was: da5cc14aaba6228683cb4e8888b835e1.
Seeing as my deployment package has not changed since the last time I successfully performed an update of my Staging environment (apart from one line of code for a bug fix) I can't see this being an issue with my package. I am hoping this is transient Azure environment issue - anyone any ideas as to what this may be?
There is a fragmentation issue in the cluster you are trying to deploy to. The ops team is engaged and working to resolve and you should be able to deploy again later tonight or tomorrow.
Some additional information:
Once you create a deployment (either prod or staging slot) in a cloud service your entire cloud service (both prod and staging slots) are pinned to a cluster of machines (there are some Mark Russinovich fabric videos with more details if you are interested). So if there is a problem in a cluster, or you try to deploy a VM size not available in the cluster such as the new D series machines, then you may fail if the specific cluster can't allocate the request. To resolve this you can deploy to a brand new cloud service which will allow the fabric to check all clusters in that datacenter/region to satisfy the allocation request.
Consider a different upgrade strategy for scenarios like this. A lot of services will upgrade by creating a new deployment in a new cloud service, thus getting a new URL and IP address, and then modify the CNAME or A Record in order to transition clients to the new service.
If you see this issue again you can usually get a fast resolution by opening a support incident - http://azure.microsoft.com/en-us/support/options/
Update: We have a new blog post that describes this scenario and the common causes - http://azure.microsoft.com/blog/2015/03/19/allocation-failure-and-remediation/.
We had a similar allocation failed issue recently deploying our Azure Cloud Service:
Azure Cloud Service Deployment Error
Allocation failed; unable to satisfy constraints in request. The requested new service deployment is bound to an Affinity Group, or it targets a Virtual Network, or there is an existing deployment under this hosted service. Any of these conditions constrains the new deployment to specific Azure resources. Please retry later or try reducing the VM size or number of role instances. Alternatively, if possible, remove the aforementioned constraints or try deploying to a different region.
Allocation Failed - Resolution
Delete Existing Cloud Service
Create New Cloud Service target different Data Center or Resource Group (upload SSL certs required)
Redeploy cloud service package
Relink VSO Team Projects
I suspect the issue has something to do with a corrupt resource group or recent Azure upgrades that were not backwards compatible with older resource groups.

Resources