diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample10_SecretReference.md b/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample10_SecretReference.md index 0ce8ae7ab3fe0..91db0502f13da 100644 --- a/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample10_SecretReference.md +++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/samples/Sample10_SecretReference.md @@ -17,7 +17,8 @@ This sample shows how to use the library to create, retrieve, and delete Secret To create a secret reference, use the `SecretReferenceConfigurationSetting` class: ```C# Snippet:Sample_CreateSecretReference -var secretReferenceSetting = new SecretReferenceConfigurationSetting("setting", new Uri("https://.vault.azure.net/secrets/")); +var secretId = "https://keyvault_name.vault.azure.net/secrets/"; +var secretReferenceSetting = new SecretReferenceConfigurationSetting("setting", new Uri(secretId)); ``` **NOTE** you can retrieve the secret identifier from the Azure Portal or using the `KeyVaultSecret.Id` property. diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/tests/AppConfigurationTestEnvironment.cs b/sdk/appconfiguration/Azure.Data.AppConfiguration/tests/AppConfigurationTestEnvironment.cs index 00d335e171728..ff9bd1b9584ea 100644 --- a/sdk/appconfiguration/Azure.Data.AppConfiguration/tests/AppConfigurationTestEnvironment.cs +++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/tests/AppConfigurationTestEnvironment.cs @@ -9,5 +9,6 @@ public class AppConfigurationTestEnvironment : TestEnvironment { public string ConnectionString => GetRecordedVariable("APPCONFIGURATION_CONNECTION_STRING", options => options.HasSecretConnectionStringParameter("secret", SanitizedValue.Base64)); public string Endpoint => GetRecordedVariable("APPCONFIGURATION_ENDPOINT_STRING"); + public string SecretId => GetRecordedVariable("KEYVAULT_SECRET_URL"); } } diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/tests/samples/Sample10_SecretReference.cs b/sdk/appconfiguration/Azure.Data.AppConfiguration/tests/samples/Sample10_SecretReference.cs index c9b61b8093739..43aa8fdb53251 100644 --- a/sdk/appconfiguration/Azure.Data.AppConfiguration/tests/samples/Sample10_SecretReference.cs +++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/tests/samples/Sample10_SecretReference.cs @@ -19,7 +19,9 @@ public async Task CreateSecretReference() var client = new ConfigurationClient(connectionString); #region Snippet:Sample_CreateSecretReference - var secretReferenceSetting = new SecretReferenceConfigurationSetting("setting", new Uri("https://.vault.azure.net/secrets/")); + var secretId = "https://keyvault_name.vault.azure.net/secrets/"; + /*@@*/ secretId = TestEnvironment.SecretId; + var secretReferenceSetting = new SecretReferenceConfigurationSetting("setting", new Uri(secretId)); #endregion #region Snippet:Sample_SetSecretReference diff --git a/sdk/appconfiguration/test-resources.json b/sdk/appconfiguration/test-resources.json index 0cc3da161f559..8430c56409975 100644 --- a/sdk/appconfiguration/test-resources.json +++ b/sdk/appconfiguration/test-resources.json @@ -56,7 +56,8 @@ "variables": { "roleDefinitionId": "[format('/subscriptions/{0}/providers/Microsoft.Authorization/roleDefinitions/5ae67dd6-50cb-40e7-96ff-dc2bfa4b606b', subscription().subscriptionId)]", "uniqueAzConfigName": "[format('{0}-{1}', parameters('baseName'), parameters('azConfigPrefix'))]", - "endpointValue": "[format('https://{0}-{1}.azconfig.io', parameters('baseName'), parameters('azConfigPrefix'))]" + "endpointValue": "[format('https://{0}-{1}.azconfig.io', parameters('baseName'), parameters('azConfigPrefix'))]", + "azureKeyVaultSecretUrl": "[format('https://{0}.vault.azure.net/secrets/TestSecret', parameters('baseName'))]" }, "resources": [ { @@ -79,10 +80,45 @@ "roleDefinitionId": "[variables('roleDefinitionId')]", "principalId": "[parameters('testApplicationOid')]" } + }, + { + "type": "Microsoft.KeyVault/vaults", + "apiVersion": "2016-10-01", + "name": "[parameters('baseName')]", + "location": "[parameters('location')]", + "properties": { + "sku": { + "family": "A", + "name": "premium" + }, + "tenantId": "[parameters('tenantId')]", + "accessPolicies": [ + { + "tenantId": "[parameters('tenantId')]", + "objectId": "[parameters('testApplicationOid')]", + "permissions": { + "secrets": [ + "get" + ] + } + } + ] + } + }, + { + "type": "Microsoft.KeyVault/vaults/secrets", + "name": "[concat(parameters('baseName'), '/TestSecret')]", + "apiVersion": "2016-10-01", + "location": "[parameters('location')]", + "dependsOn": [ + "[resourceId('Microsoft.KeyVault/vaults', parameters('baseName'))]" + ], + "properties": { + "value": "Very secret value" + } } ], "outputs": { - "APPCONFIGURATION_CONNECTION_STRING": { "type": "string", "value": "[listKeys(resourceId('Microsoft.AppConfiguration/configurationStores',variables('uniqueAzConfigName')), '2019-02-01-preview').value[0].connectionString]" @@ -90,6 +126,10 @@ "APPCONFIGURATION_ENDPOINT_STRING": { "type": "string", "value": "[variables('endpointValue')]" + }, + "KEYVAULT_SECRET_URL": { + "type": "string", + "value": "[variables('azureKeyVaultSecretUrl')]" } } }