- Package Name: azure.keyvault.secrets.SecretClient
- Package Version: 4.7.0
- Operating System: Amazon Linux 2
- Python Version: 3.8.16
Describe the bug
When constructing the SecretClient with a custom domain name for the Azure Vault URL and calling list_properties_of_secrets() method, the nextlink for the ItemPaged iterator returns the default public Vault URL.
This causes subsequent iterations to fail.
To Reproduce
- Connecting to Azure Key Vault using a Private Endpoint with an Azure Application Gateway
- The problem may also exist if just using a Private Endpoint without Azure Application Gateway
- Custom DNS record resolves to the front end of the Azure Application Gateway
- Construct the SecretClient with the vault_url set to the URL of the Application Gateway
- Call SecretClient.list_properties_of_secrets()
- If the number of secrets exceeds the page and a nextlink is returned for the ItemPaged iterator, the nextlink is set to the public URL of the Key Vault
- The next API calls to Key Vault Secrets uses the public vault URL
Expected behavior
The nextlink URL should match the FQDN of the original vault_url supplied to the SecretClient
Verbose Logs Output
18/04/2023 07:45:06: DEBUG: https://my-example-key-vault.custom.domain.name:443 "GET /secrets?api-version=7.4 HTTP/1.1" 200 6307
18/04/2023 07:45:06: INFO: Response status: 200
Response headers:
'Date': 'Tue, 18 Apr 2023 07:45:06 GMT'
'Content-Type': 'application/json; charset=utf-8'
'Content-Length': '6307'
'Connection': 'keep-alive'
'Cache-Control': 'no-cache'
'Pragma': 'no-cache'
'Expires': '-1'
'x-ms-keyvault-region': 'eastasia'
'x-ms-client-request-id': 'REDACTED'
'x-ms-request-id': 'REDACTED'
'x-ms-keyvault-service-version': '1.9.775.1'
'x-ms-keyvault-network-info': 'conn_type=PrivateLink;private_endpoint=/subscriptions/REDACTED/resourceGroups/REDACTED/providers/Microsoft.Network/privateEndpoints/REDACTED;addr=REDACTED;act_addr_fam=InterNetworkV6;'
'X-Content-Type-Options': 'REDACTED'
'Strict-Transport-Security': 'REDACTED'
18/04/2023 07:45:06: DEBUG: Response status: '200'
Response headers:
'Date': 'Tue, 18 Apr 2023 07:45:06 GMT'
'Content-Type': 'application/json; charset=utf-8'
'Content-Length': '6307'
'Connection': 'keep-alive'
'Cache-Control': 'no-cache'
'Pragma': 'no-cache'
'Expires': '-1'
'x-ms-keyvault-region': 'eastasia'
'x-ms-client-request-id': 'REDACTED'
'x-ms-request-id': 'REDACTED'
'x-ms-keyvault-service-version': '1.9.775.1'
'x-ms-keyvault-network-info': 'conn_type=PrivateLink;private_endpoint=/subscriptions/REDACTED/resourceGroups/REDACTED/providers/Microsoft.Network/privateEndpoints/REDACTED;addr=REDACTED;act_addr_fam=InterNetworkV6;'
'X-Content-Type-Options': 'nosniff'
'Strict-Transport-Security': 'max-age=31536000;includeSubDomains'
Response content:
{"value":[REDACTED],"nextLink":"https://REDACTED.vault.azure.net:443/secrets?api-version=7.4&$skiptoken=REDACTED"}
18/04/2023 07:45:06: DEBUG: Request URL: 'https://REDACTED.azure.net:443/secrets?api-version=7.4&$skiptoken=REDACTED'
Request method: 'GET'
Request headers:
'x-ms-client-request-id': 'REDACTED'
'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.8.16 (Linux-4.14.296-222.539.amzn2.x86_64-x86_64-with-glibc2.2.5)'
Request body:
This request has no body
18/04/2023 07:45:06: INFO: Request URL: 'https://REDACTED.vault.azure.net:443/secrets?api-version=REDACTED&$skiptoken=REDACTED'
Request method: 'GET'
Request headers:
'x-ms-client-request-id': 'REDACTED'
'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.8.16 (Linux-4.14.296-222.539.amzn2.x86_64-x86_64-with-glibc2.2.5)'
No body was attached to the request
18/04/2023 07:45:06: DEBUG: Starting new HTTPS connection (1): REDACTED.vault.azure.net:443
18/04/2023 07:47:15: DEBUG: Request URL: 'https://REDACTED.vault.azure.net:443/secrets?api-version=7.4&$skiptoken=REDACTED'
Request method: 'GET'
Request headers:
'x-ms-client-request-id': 'REDACTED'
'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.8.16 (Linux-4.14.296-222.539.amzn2.x86_64-x86_64-with-glibc2.2.5)'
Request body:
This request has no body
18/04/2023 07:47:15: INFO: Request URL: 'https://REDACTED.vault.azure.net:443/secrets?api-version=REDACTED&$skiptoken=REDACTED'
Request method: 'GET'
Request headers:
'x-ms-client-request-id': 'REDACTED'
'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.8.16 (Linux-4.14.296-222.539.amzn2.x86_64-x86_64-with-glibc2.2.5)'
No body was attached to the request
Describe the bug
When constructing the SecretClient with a custom domain name for the Azure Vault URL and calling list_properties_of_secrets() method, the nextlink for the ItemPaged iterator returns the default public Vault URL.
This causes subsequent iterations to fail.
To Reproduce
Expected behavior
The nextlink URL should match the FQDN of the original vault_url supplied to the SecretClient
Verbose Logs Output
18/04/2023 07:45:06: DEBUG: https://my-example-key-vault.custom.domain.name:443 "GET /secrets?api-version=7.4 HTTP/1.1" 200 6307
18/04/2023 07:45:06: INFO: Response status: 200
Response headers:
'Date': 'Tue, 18 Apr 2023 07:45:06 GMT'
'Content-Type': 'application/json; charset=utf-8'
'Content-Length': '6307'
'Connection': 'keep-alive'
'Cache-Control': 'no-cache'
'Pragma': 'no-cache'
'Expires': '-1'
'x-ms-keyvault-region': 'eastasia'
'x-ms-client-request-id': 'REDACTED'
'x-ms-request-id': 'REDACTED'
'x-ms-keyvault-service-version': '1.9.775.1'
'x-ms-keyvault-network-info': 'conn_type=PrivateLink;private_endpoint=/subscriptions/REDACTED/resourceGroups/REDACTED/providers/Microsoft.Network/privateEndpoints/REDACTED;addr=REDACTED;act_addr_fam=InterNetworkV6;'
'X-Content-Type-Options': 'REDACTED'
'Strict-Transport-Security': 'REDACTED'
18/04/2023 07:45:06: DEBUG: Response status: '200'
Response headers:
'Date': 'Tue, 18 Apr 2023 07:45:06 GMT'
'Content-Type': 'application/json; charset=utf-8'
'Content-Length': '6307'
'Connection': 'keep-alive'
'Cache-Control': 'no-cache'
'Pragma': 'no-cache'
'Expires': '-1'
'x-ms-keyvault-region': 'eastasia'
'x-ms-client-request-id': 'REDACTED'
'x-ms-request-id': 'REDACTED'
'x-ms-keyvault-service-version': '1.9.775.1'
'x-ms-keyvault-network-info': 'conn_type=PrivateLink;private_endpoint=/subscriptions/REDACTED/resourceGroups/REDACTED/providers/Microsoft.Network/privateEndpoints/REDACTED;addr=REDACTED;act_addr_fam=InterNetworkV6;'
'X-Content-Type-Options': 'nosniff'
'Strict-Transport-Security': 'max-age=31536000;includeSubDomains'
Response content:
{"value":[REDACTED],"nextLink":"https://REDACTED.vault.azure.net:443/secrets?api-version=7.4&$skiptoken=REDACTED"}
18/04/2023 07:45:06: DEBUG: Request URL: 'https://REDACTED.azure.net:443/secrets?api-version=7.4&$skiptoken=REDACTED'
Request method: 'GET'
Request headers:
'x-ms-client-request-id': 'REDACTED'
'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.8.16 (Linux-4.14.296-222.539.amzn2.x86_64-x86_64-with-glibc2.2.5)'
Request body:
This request has no body
18/04/2023 07:45:06: INFO: Request URL: 'https://REDACTED.vault.azure.net:443/secrets?api-version=REDACTED&$skiptoken=REDACTED'
Request method: 'GET'
Request headers:
'x-ms-client-request-id': 'REDACTED'
'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.8.16 (Linux-4.14.296-222.539.amzn2.x86_64-x86_64-with-glibc2.2.5)'
No body was attached to the request
18/04/2023 07:45:06: DEBUG: Starting new HTTPS connection (1): REDACTED.vault.azure.net:443
18/04/2023 07:47:15: DEBUG: Request URL: 'https://REDACTED.vault.azure.net:443/secrets?api-version=7.4&$skiptoken=REDACTED'
Request method: 'GET'
Request headers:
'x-ms-client-request-id': 'REDACTED'
'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.8.16 (Linux-4.14.296-222.539.amzn2.x86_64-x86_64-with-glibc2.2.5)'
Request body:
This request has no body
18/04/2023 07:47:15: INFO: Request URL: 'https://REDACTED.vault.azure.net:443/secrets?api-version=REDACTED&$skiptoken=REDACTED'
Request method: 'GET'
Request headers:
'x-ms-client-request-id': 'REDACTED'
'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.8.16 (Linux-4.14.296-222.539.amzn2.x86_64-x86_64-with-glibc2.2.5)'
No body was attached to the request