Sep 08 2023
08:51 AM
- last edited on
Mar 05 2024
03:01 PM
by
TechCommunityAP
Sep 08 2023
08:51 AM
- last edited on
Mar 05 2024
03:01 PM
by
TechCommunityAP
Hi,
I have a query regarding my Azure DevOps Pipeline. I am running a DevOps pipeline where I am running a PowerShell script that will generate an assessment report about my Azure subscription. In that report, we will get all the details about my subscription like what type of resources and how many resources are there.
So the script working fine and I am getting the desired result.
Now let's talk about what is the problem I am facing:-
Iaas Migrations-Staging Subscription.
My Script gives me the assessment report of this subscription because I have set this subscription in my Azure CLI using these commands:-
az login --tenant <your_tenant_id>
az account set --subscription <your_subscription_id>
az login --tenant <your_tenant_id>
az account set --subscription <your_subscription_id>
and set another tenant and another subscription in her Azure CLI. So right now in her machine, the currently logged subscription is Azure Stagging Subscription.
**
So, now my teammate running this command on her machine
az pipelines run --name AssessmentTool_Report-CI --org https://dev.azure.com/DheemanDas --project test
This command again triggers the Azure pipeline but after the pipeline execution is finished we can see that it generates an assessment report for this subscription **Iaas Migrations-Staging Subscription. But my teammate set this subscription Azure Stagging Subscription in her machine. I want that I can give access to anyone inside my Azure DevOps project and they set their desired subscription in their local machine trigger the pipeline and generate the assessment report for their subscription.
one thing to keep in mind is that in this whole process, I am using my laptop as a self-hosted agent. but my teammate does not.
Can anyone give me a proper solution for this problem without installing self-hosted on everyone's machine? Rather I am just using my machine as a self-hosted agent and I can give access to anyone inside my Azure DevOps project and they set their desired subscription in their local machine trigger the pipeline and generate the assessment report for their subscription.
I hope you understand my question and the scenario that I want to explain.**
Please help me.
Thanks in advance:)
Sep 09 2023 08:37 PM
Sep 11 2023 10:45 PM
Your solution is not working. It is taking the Azure Subscription that is set in my Powershell. In my machine subscription "B" is set. So, I have cleared all my set subscriptions in my PowerShell by this command Clear-AzContext -Force. After that, my teammate set the Azure subscription in his machine-like he set a subscription "A".Now it should take subscription "A" and generate an assessment report about subscription "A". So, when he ran this command to trigger my pipeline az pipelines run --name AssessmentTool_Report-CI --orghttps://dev.azure.com/DheemanDas--project test. But It is taking the subscription "B" that is set in my machine. But I have cleared all my set subscriptions in the machine using this command Clear-AzContext -Force. Then why it is taking subscription B Why it is not taking my teammate's subscription that he set in his machine?
Can you please help me to solve this issue? How can I fix it permanently?
Sep 12 2023 06:27 AM - edited Sep 12 2023 06:29 AM
- pwsh: Write-Host "##vso[task.setendpoint id={YOUR SERVICE CONNECTION ID HERE};field=dataParameter;key=subscriptionId]${{ parameters.SubscriptionId }}"
displayName: Set Subscription
3. Then change the task type for your script that you wrote. Use the Azure CLI task with powershell and use this Service Connection that you created. Now it should authenticate to the subscription you passed in and execute your script in that context. It will not matter what you logged into last on your local machine.
Sep 12 2023 08:47 AM
Sep 12 2023 10:25 AM