You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Given a secret to store, create it in key vault.
SecretClientsecretClient = SecretClient.builder()
.endpoint("https://myvault.vault.azure.net/")
.credentials(AzureCredential.DEFAULT)
.build();
Secretsecret = secretClient.setSecret("secretName", "secretValue").value();
System.out.printf("Secret is created with name %s and value %s \n", secret.name(), secret.value());
2. Given a secret which expires in 1 year, create it in key vault.
SecretClientsecretClient = SecretClient.builder()
.endpoint("https://myvault.vault.azure.net/")
.credentials(AzureCredential.DEFAULT)
.build();
SecretcreatedSecret = secretClient.setSecret(newSecret("secretName", "secretValue")
.expires(OffsetDateTime.now().plusYears(1)))
.value();
System.out.printf("Secret is created with name %s and value %s \n", createdSecret.name(), createdSecret.value());
3. Given a secret named "StorageAccountKey" whose expiry got changed to 2 years from today, update it in key vault.
1. Given a secret to store, create it in key vault.
SecretAsyncClientsecretAsyncClient = SecretAsyncClient.builder()
.endpoint("https://myvault.vault.azure.net/")
.credentials(AzureCredential.DEFAULT)
.build();
secretAsyncClient.setSecret("secretName", "secretValue").subscribe(secretResponse ->
System.out.printf("Secret is created with name %s and value %s \n", secretResponse.value().name(), secretResponse.value().value()));
2. Given a secret which expires in 1 year, create it in key vault.
SecretAsyncClientsecretAsyncClient = SecretAsyncClient.builder()
.endpoint("https://myvault.vault.azure.net/")
.credentials(AzureCredential.DEFAULT)
.build();
Secretsecret = newSecret("secretName", "secretValue")
.expires(OffsetDateTime.now().plusYears(1));
secretAsyncClient.setSecret(secret).subscribe(secretResponse ->
System.out.printf("Secret is created with name %s and value %s \n", secretResponse.value().name(), secretResponse.value().value()));
3. Given a secret named "StorageAccountKey" whose expiry got changed to 2 years from today, update it in key vault.
SecretAsyncClientsecretAsyncClient = SecretAsyncClient.builder()
.endpoint("https://myvault.vault.azure.net/")
.credentials(AzureCredential.DEFAULT)
.build();
secretAsyncClient.getSecret("StorageAccountKey").subscribe(secretResponse -> {
Secretsecret = secretResponse.value();
//Update the expiry time of the secret.secret.expires(OffsetDateTime.now().plusYears(2));
secretAsyncClient.updateSecret(secret).subscribe(updatedSecretResponse ->
System.out.printf("Secret's updated expiry time %s \n", updatedSecretResponse.value().notBefore().toString()));
});
4. Given a secret named "EventhubsAccountKey" which is no longer needed, delete it.