private async Task<string> GetChannelIntegrityKey()
{
ResourceExtendedInformation extendedInformation = null;
try
{
extendedInformation = await this.GetExtendedInfo();
}
catch (Exception exception)
{
CloudException cloudException = exception as CloudException;
if (cloudException != null && cloudException.Response != null && !string.IsNullOrEmpty(cloudException.Response.Content))
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
rpError.Error error = serializer.Deserialize<rpError.Error>(cloudException.Response.Content);
if (error.ErrorCode.Equals(RpErrorCode.ResourceExtendedInfoNotFound.ToString(), StringComparison.InvariantCultureIgnoreCase))
{
extendedInformation = new ResourceExtendedInformation();
}
}
}
if (null == extendedInformation.Properties)
{
extendedInformation = this.CreateVaultExtendedInformation();
}
else
{
if (!extendedInformation.Properties.Algorithm.Equals(CryptoAlgorithm.None.ToString(), StringComparison.InvariantCultureIgnoreCase))
{
// In case this condition is true that means the credential was first generated in portal
// and hence can not be fetched here.
throw new CloudException(Resources.VaultSettingsGenerationUnSupported);
}
}
return extendedInformation.Properties.IntegrityKey;
}