Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.26k stars 3.86k forks source link

Get-AzDataFactoryV2LinkedService does not return keyvault name in the linkedeservice of type "Azure SQL Database" #22298

Closed Ranjit-Kumar-Konjeti closed 1 year ago

Ranjit-Kumar-Konjeti commented 1 year ago

Description

Get-AzDataFactoryV2LinkedService does not return reference keyvault name in the linkedeservice of type "Azure SQL Database"

The below code only returns referenceName as "KeyVault" but it does not return actual keyvault name.

$linkedservicejson.typeProperties.connectionString.store.referenceName

referenceName type


KeyVault LinkedServiceReference

Issue script & Debug output

$linkedServices = Get-AzDataFactoryV2LinkedService -DataFactoryName $dataFactoryName -ResourceGroupName $resourceGroupName
    $DFlinkedServicesObject = [PSCustomObject] @()
    foreach ($linkedService in $linkedServices) {   

       Write-Output $linkedservicejson.typeProperties.connectionString.store.referenceName

}

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.5
PSEdition                      Core
GitCommitId                    7.3.5
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.12.3                Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script     1.16.13               Az.DataFactory                      {Add-AzDataFactoryV2DataFlowDebugSessionPackage, Add-AzDataFactoryV2TriggerSubscription, Get-AzDataFactory, Get-AzDataFactoryActivityWindow…}
Script     6.7.0                 Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…}

Error output

referenceName type
------------- ----
KeyVault      LinkedServiceReference
ghost commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

SaurabhSharma-MSFT commented 1 year ago

@Ranjit-Kumar-Konjeti Can you please provide the full code as it looks like the code which you have shared is incomplete and it is missing use of $DFlinkedServicesObject and $linkedservicejson.

Ranjit-Kumar-Konjeti commented 1 year ago

@SaurabhSharma-MSFT - do not worry about the missing code. main method is "Get-AzDataFactoryV2LinkedService". you can create a Datafactory and add linked service of type sqldatabase and then use keyvault secret instead of sql connection string and use the code below(by giving your datafactoryname and resourcegroupname) to list the linkedservices of type sqldatabase and type "AzureKeyVaultSecret" and try to get the keyvault name from there. I tried using Azure powershell, az cli and rest api. all 3 of them does not return keyvault name. Hope I am clear.

Get-AzDataFactoryV2LinkedService -DataFactoryName $dataFactoryName -ResourceGroupName $resourceGroupName

SaurabhSharma-MSFT commented 1 year ago

@Ranjit-Kumar-Konjeti I am not able to reproduce this issue. I referring to Azure Key Vault to get SQL connection string and Key Vault name connection name correctly appears in the results output. Please see below the screenshot - image You can find the connection string properties under Properties.AdditionalProperties of the returned result set. Please try to fetch the Properties of your returned linked service. Are you expecting the actual Keyvault name in the result set? I don't think cmdlet will return that as the Json result set includes the linked service connection name from ADF which is configured for the Azure Key vault.

Ranjit-Kumar-Konjeti commented 1 year ago

Yes we are expecting the keyvault name not just the reference name, in this case how do we know which keyvault name it is referenced to?

SaurabhSharma-MSFT commented 1 year ago

@Ranjit-Kumar-Konjeti If you want to know actual Key Vault name then use the same cmdlet again by passing the Azure Key vault linked service referencename like below - image Please let me know if you have any other questions.

Ranjit-Kumar-Konjeti commented 1 year ago

ok let me check and get back to you. Thanks!

ghost commented 1 year ago

Hi @Ranjit-Kumar-Konjeti. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

ghost commented 1 year ago

Hi @Ranjit-Kumar-Konjeti, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

Ranjit-Kumar-Konjeti commented 1 year ago

@SaurabhSharma-MSFT , this one still does not work . I think you are referring to LinkedServiceType "keyvault". I can see the keyvault name from there but that is not what I am asking for. I am checking for LinkedServiceType "AzureSqlDatabaseLinkedService" and then get the Properties of that object where it references erither sql db connection or keyvault connection. I am looking keyvault name from that keyvault connection image

image

image

Ranjit-Kumar-Konjeti commented 1 year ago

@SaurabhSharma-MSFT - could you please re open the issue and check once.