Skip to content

Commit

Permalink
use lazy init for data-plane keyvault client (#1219)
Browse files Browse the repository at this point in the history
  • Loading branch information
weidongxu-microsoft authored Mar 12, 2021
1 parent 2c1a3e3 commit dbdccff
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Samples/Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.5" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.20" />
<PackageReference Include="CoreFTP" Version="1.2.0" />
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="0.0.2-preview" />
Expand Down
2 changes: 1 addition & 1 deletion Tests/AzSdk.test.reference.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="4.3.0" />
<PackageReference Include="SSH.NET" Version="2016.0.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
<PackageReference Include="System.Net.Http" Version="4.3.2" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />

<!-- This is needed for discovering tests in test explorer -->
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/AzSdk.reference.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.4' ">
<PackageReference Include="System.Net.Http" Version="4.3.0"/>
<PackageReference Include="System.Net.Http" Version="4.3.4"/>
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.4' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.ResourceManager.Fluent" Version="$(FluentVersion)" />
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.5" />
</ItemGroup>


Expand Down
10 changes: 5 additions & 5 deletions src/ResourceManagement/KeyVault/VaultImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal partial class VaultImpl :
IDefinition,
IUpdate
{
private IKeyVaultClient client;
private Lazy<IKeyVaultClient> client;
private IKeys keys;
private ISecrets secrets;
private IGraphRbacManager graphRbacManager;
Expand All @@ -49,7 +49,7 @@ internal VaultImpl(string name, VaultInner innerObject, IKeyVaultManager manager
this.accessPolicies.Add(new AccessPolicyImpl(entry, this));
}
}
this.client = new KeyVaultClientInternal(Manager.RestClient.Credentials, Manager.RestClient.RootHttpHandler, Manager.RestClient.Handlers.ToArray());
this.client = new Lazy<IKeyVaultClient>(() => new KeyVaultClientInternal(Manager.RestClient.Credentials, Manager.RestClient.RootHttpHandler, Manager.RestClient.Handlers.ToArray()));
}

///GENMHASH:FAAD3C3E07174E29B21DE058D968BBF7:A534A23FE2D228AC3080C1CF07E66439
Expand Down Expand Up @@ -149,7 +149,7 @@ public IKeys Keys
{
if (keys == null)
{
keys = new KeysImpl(client, this);
keys = new KeysImpl(client.Value, this);
}
return keys;
}
Expand All @@ -161,13 +161,13 @@ public ISecrets Secrets
{
if (secrets == null)
{
secrets = new SecretsImpl(client, this);
secrets = new SecretsImpl(client.Value, this);
}
return secrets;
}
}

IKeyVaultClient IVaultBeta.Client => client;
IKeyVaultClient IVaultBeta.Client => client.Value;

///GENMHASH:577E5E9CE0B513EB5189E6F44BB732C7:3949CE4CBC4994E8C88DF2E4815A8696
public VaultImpl WithEmptyAccessPolicy()
Expand Down

0 comments on commit dbdccff

Please sign in to comment.