Deploy azure subscription using azure devops pipeline - azure

I'm trying to deploy a new azure subscription into a management group using azure devops pipeline.
I have created a management group and a service principle , I assign the contributor role on the mgm group to the sp and then created a new service connection on the management group scope.
My problem is that I can not find this service connection in my pipeline task.
How can I use this service connection in my pipeline to deploy subscription?

According to your description, you could add the "ARM Template deployment" task in the azure pipeline to deploy a new azure subscription into a management group.
In classic pipeline:
For more information about the ARM of the mangement group, you could refer to this documentation.

Related

Why do I need to specify a Service Principal in Azure Resource Manager service connection in Azure DevOps?

I want to use the "ARM template deployment" task in Azure pipelines, and for this, I need to set up a service connection of type "Azure Resource Manager connection". So I head over to the Service connections pane. And it turns out that in order to configure this service connection, one of the authentication methods is using a service principal.
So I'v tried learning a little bit about service principals, and what I've understood so far is as such:
App registration is the process of registering applications which I want to delegate identity and access management to Azure AD for. A service principal is a concrete instantiation of the Application object that I create in my Azure AD tenant.
I didn't yet get my head around all these concepts well enough, but what I don't even start to understand is what does all that have to do with an authentication method for a Azure Resource Manager service connection in Azure DevOps??
Can someone please clear up the fog for me?
Azure Devops is not integrated with Azure portal by any means. Also, Azure Devops is not a trusted service even by Microsoft itself.
The Service Connection will help you to establish a connection between Azure portal and Azure Devops. Here, the service principal acts like a user account to establish the connection.
First of all, for using the task "ARM template deployment" in Azure DevOps pipeline, this task is used to deploy Azure Resource Manager templates at resource group deployment scope, subscription deployment scope and management group deployment scopes. The task is also used to create or update a resource group in Azure.
And you should select your Azure Resource and specified subscription which are the prerequisites of the task usage, then for connecting to a subscription which is associated with an Azure Active Directory tenant when building pipeline, it is needed to create a Service connection to help work between pipeline and connect to Azure Subscription. For more info, you can refer to doc:
Azure DevOps Connection Services. And you should also login authenticate via service principle instead of user, it is just like Azure log in.
Besides, you can also manage your Azure subscriptions at scale with management groups via this doc: Organize subscriptions into management groups and assign roles to users for Microsoft Defender for Cloud | Microsoft Learn .

Service Connection in Azure Devops for 2 Subscriptions

I am using Azure Devops Pipelines. In my CI yaml and calling a powershell script. Within Powershell i am reading details of an existing resource say storage account sitting in subscription X, and creating an exact replica in subscription Y. We have created a Service connection using service principal of X in Azure devops and are using in our CI pipeline. Not aware of how to include Y Service Principal so that resource can be created in Y subscription.
Anything can be handled at Azure side? Please suggest the way.

Could not determine if Azure DevOps belongs to a Azure subscription

I am an owner of an Azure DevOps Organization - e.g. "lab.visualstudio.com". We are planning to decommission our Azure subscription. I try to find out if the decommission will affect my Azure DevOps Org.
I can see "lab.visualstudio.com" is connecting to my Azure subscription for billing purposes. However, I could not find "lab.visualstudio.com" in my Azure portal.
Is there a way to determine if "lab.visualstudio.com" belongs to one Azure subscription? In other words, how can I know if decommissioning my Azure subscription will also decommission my Azure DevOps Organization?
Thanks in advance!
Notes: I saw someone's Azure portal has their Azure DevOps Organisation on it (screenshot attached). I am wondering why mine does not show in my Azure portal.
Is there a way to determine if "lab.visualstudio.com" belongs to one
Azure subscription?
To find the Azure Subscription associated with your Azure DevOps organization, login into Azure DevOps, go to Organization Settings and then Billing. You will see the Azure Subscription used for billing of Azure DevOps organization.
You can then go to Azure Portal and navigate to the subscription and look under resources. You should see a resource by the name lab (or the name of your Azure DevOps Organization) of type Azure DevOps organization there.
In other words, how can I know if decommissioning my Azure
subscription will also decommission my Azure DevOps Organization?
Azure DevOps uses an Azure Subscription for billing purposes. If you delete the Azure Subscription that is associated with your Azure DevOps organization, your Azure DevOps organization will be immediately moved to "Free Tier". Though I have not tried it but I believe that the resources you have created in your Azure DevOps organization will not be deleted. I'm not sure what would happen if you have provisioned resources more than allowed in free tier.
You can read more about it here: https://learn.microsoft.com/en-us/azure/devops/organizations/billing/billing-faq?view=azure-devops#what-happens-if-i-delete-my-organization-resource--.

Subscription is not populating in Azure Release Pipeline

I have created Azure Build Pipeline and now want to create the Release Pipeline. On the release tab, I am unable to see any subscription whereas I do have subscription which I can use in the Portal.azure.com.
Please help.
Subscription is not populating in Azure Release Pipeline
There is no such Subscription in the Azure realease pipeline tab directly.
To use the subscription in the release pipeline, we need to create a service connection to connect the azure Portal via subscription:
Project Settings-> Service connections-> Azure Resource Manager:
Then we could use this connection for the task, like Azure CLI:

Azure DevOps Pipelines not respecting RBAC permissions

I've configured Azure DevOps with a Service Principal to access one specific resource group. I was expecting Azure DevOps will only be able to deploy to resources under this group but that doesn't seem to be the case. I am able to connect agents from other resource groups and then deploy to them without any issue.
What's the point of configuring Service Principal in 'Azure DevOps' if the agent can bypass all permissions?
Configuration:
Azure Portal
1. Created AD in Azure Portal. Created App under AD with client secret.
2. Granted 'contributor' role to App created in Step-1 with resource group scope.
3. Created two resource groups - RG1 and RG2 with one VM in each.
4. Granted role assignment to App created in step-1 for RG1 only. RG2 has no role assignments.
Azure DevOps
5. Connect Azure DevOps organization with Portal using AD connect.
6. Created service connection by going to Projects-> Service Principal(SP) -> Azure Resource Manager with Service Principal credentials (see step-1 above).
7. Created new pipeline and deployment group. Copied the deployment group agent code and ran it on both VMs in RG1 and RG2.
Actual Result:
Both VMs connected fine as targets under deployment group.
Pipeline was able to deploy successfully to both VMs.
Even if no service connections exist, pipelines are able to deploy to VMs
Expected Result:
Only VM under RG1 should connect based on RBAC.
Pipeline should only be able to deploy to VM under RG1 and not RG2.
Pipelines shouldn't be able to deploy if service connections are not defined.
Workaround: Maybe installing this extension ( https://github.com/maikvandergaag/msft-extensions/wiki/Azure-RBAC ) would help but I was trying to avoid it if possible.
I believe your understanding on RBAC applies the Azure resources and the VM Resources. But you have already override the permission by installing the Deployment agent into the VM.
In the IAAS scenario, you have already granted permission using the deployment agent.
In the PAAS Scenario, RBAC will be adhered because you will be using service end point.

Resources