Skip to content

Commit b07f68c

Browse files
authored
Release 1.19 bugfixes (#573)
* Fixed null ref exception in WebApps. * Fixing other bool cast issues in WebApps. * Fixed CosmosDB internal mapping issue. * Fixed build breaks and upgraded CR to the latest.
1 parent 5517338 commit b07f68c

File tree

10 files changed

+5163
-22
lines changed

10 files changed

+5163
-22
lines changed

Samples/Samples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
<ItemGroup>
3131
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.1" />
32-
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.17" />
32+
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.18" />
3333
<PackageReference Include="CoreFTP" Version="1.2.0" />
3434
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="0.0.2-preview" />
3535
<PackageReference Include="SSH.NET" Version="2016.0.0" />

Tests/AzSdk.test.reference.props

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<Import Project="$([MSBuild]::GetPathOfFileAbove('test.props'))" />
33
<ItemGroup>
4-
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.3.4" />
4+
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.3.6" />
55
<PackageReference Include="Microsoft.Azure.Test.HttpRecorder" Version="1.12.0" />
66
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework" Version="1.7.4" />
77
<PackageReference Include="SSH.NET" Version="2016.0.0" />
@@ -11,4 +11,7 @@
1111
<!-- This is needed for discovering tests in test explorer -->
1212
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
1313
</ItemGroup>
14+
<PropertyGroup>
15+
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
16+
</PropertyGroup>
1417
</Project>

Tests/Fluent.Tests/CosmosDB/CosmosDBTest.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Fluent.Tests.Common;
66
using Microsoft.Azure.Management.CosmosDB.Fluent;
77
using Microsoft.Azure.Management.CosmosDB.Fluent.Models;
8+
using Microsoft.Azure.Management.Network.Fluent.Models;
89
using Microsoft.Azure.Management.ResourceManager.Fluent.Core;
910
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
1011
using Xunit;
@@ -70,5 +71,63 @@ public void CosmosDBCRUD()
7071

7172
}
7273
}
74+
75+
76+
[Fact]
77+
public void CosmosDBBugfix()
78+
{
79+
using (var context = FluentMockContext.Start(GetType().FullName))
80+
{
81+
var dbName = TestUtilities.GenerateName("db");
82+
var saName = TestUtilities.GenerateName("dbsa");
83+
var rgName = TestUtilities.GenerateName("ddbRg");
84+
var manager = TestHelper.CreateCosmosDB();
85+
var resourceManager = TestHelper.CreateResourceManager();
86+
ICosmosDBAccount databaseAccount = null;
87+
var azure = TestHelper.CreateRollupClient();
88+
89+
try
90+
{
91+
databaseAccount = manager.CosmosDBAccounts.Define(dbName)
92+
.WithRegion(Region.USWest)
93+
.WithNewResourceGroup(rgName)
94+
.WithKind(DatabaseAccountKind.GlobalDocumentDB)
95+
.WithSessionConsistency()
96+
.WithWriteReplication(Region.USWest)
97+
.WithReadReplication(Region.USCentral)
98+
.WithIpRangeFilter("")
99+
.Create();
100+
101+
// BUGFIX
102+
var vn = azure.Networks.Define(dbName)
103+
.WithRegion(Region.USWest)
104+
.WithNewResourceGroup(rgName)
105+
.WithAddressSpace("192.168.0.0/16")
106+
.DefineSubnet("subnet1")
107+
.WithAddressPrefix("192.168.1.0/24")
108+
.WithAccessFromService(ServiceEndpointType.MicrosoftAzureCosmosDB)
109+
.Attach()
110+
.DefineSubnet("subnet2")
111+
.WithAddressPrefix("192.168.2.0/24")
112+
.WithAccessFromService(ServiceEndpointType.MicrosoftAzureCosmosDB)
113+
.Attach()
114+
.Create();
115+
116+
117+
databaseAccount.Update().WithVirtualNetwork(vn.Id, "Subnet1").Apply();
118+
databaseAccount.Update().WithVirtualNetwork(vn.Id, "Subnet1").Apply();
119+
databaseAccount.Update().WithVirtualNetwork(vn.Id, "Subnet1").Apply();
120+
// END of BUGFIX
121+
}
122+
finally
123+
{
124+
try
125+
{
126+
resourceManager.ResourceGroups.BeginDeleteByName(rgName);
127+
}
128+
catch { }
129+
}
130+
}
131+
}
73132
}
74133
}

Tests/Fluent.Tests/SessionRecords/Fluent.Tests.CosmosDB/CosmosDBBugfix.json

Lines changed: 5066 additions & 0 deletions
Large diffs are not rendered by default.

src/AzSdk.reference.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.props'))" />
33
<ItemGroup>
4-
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="[2.3.17, 3.0.0)" />
4+
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="[2.3.18, 3.0.0)" />
55
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="[3.3.18, 4.0.0)" />
66
</ItemGroup>
77

src/ResourceManagement/AppService/WebAppBaseImpl.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ internal SiteConfigResourceInner SiteConfig
9090
}
9191
}
9292

93-
public bool HttpsOnly => (bool) Inner.HttpsOnly;
93+
public bool HttpsOnly => Inner.HttpsOnly ?? false;
9494

9595
public FtpsState FtpsState => SiteConfig?.FtpsState;
9696

9797
public IList<VirtualApplication> VirtualApplications => SiteConfig?.VirtualApplications;
9898

99-
public bool Http20Enabled => (bool)SiteConfig?.Http20Enabled;
99+
public bool Http20Enabled => (SiteConfig == null || SiteConfig.Http20Enabled == null) ? false : SiteConfig.Http20Enabled.Value;
100100

101-
public bool LocalMySqlEnabled => (bool)SiteConfig?.LocalMySqlEnabled;
101+
public bool LocalMySqlEnabled => (SiteConfig == null || SiteConfig.LocalMySqlEnabled == null) ? false : SiteConfig.LocalMySqlEnabled.Value;
102102

103103
public ScmType ScmType => SiteConfig?.ScmType;
104104

src/ResourceManagement/AppService/WebAppDiagnosticLogsImpl.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ public FluentImplT Attach()
110110
///GENMHASH:A6C3024A0F426DA6CF8B71DEF91E0C7E:9FE8762C1B9FACF15AB88DA1BF9597EC
111111
public bool DetailedErrorMessages()
112112
{
113-
return Inner.DetailedErrorMessages != null && (bool) Inner.DetailedErrorMessages.Enabled;
113+
return Inner.DetailedErrorMessages != null && Inner.DetailedErrorMessages.Enabled.HasValue && Inner.DetailedErrorMessages.Enabled.Value;
114114
}
115115

116116
///GENMHASH:34AF806990F25131F59A6070440823E0:A95CC561E4445BE3E7269A572A6BFCB2
117117
public bool FailedRequestsTracing()
118118
{
119-
return Inner.FailedRequestsTracing != null && (bool) Inner.FailedRequestsTracing.Enabled;
119+
return Inner.FailedRequestsTracing != null && Inner.FailedRequestsTracing.Enabled.HasValue && Inner.FailedRequestsTracing.Enabled.Value;
120120
}
121121

122122
///GENMHASH:ADA7023132C677B8E810845941E988DA:1964CEE67CCBAFF2114B8BBEF6D87DFA
@@ -235,11 +235,11 @@ public WebAppDiagnosticLogsImpl<FluentT, FluentImplT, DefAfterRegionT, DefAfterG
235235
///GENMHASH:27B58505EB32F2C2A1069A5602161EB9:31DDB75D31D02F6E8C830CE7A9E778D3
236236
public WebAppDiagnosticLogsImpl<FluentT, FluentImplT, DefAfterRegionT, DefAfterGroupT, UpdateT> WithLogRetentionDays(int retentionDays)
237237
{
238-
if (Inner.HttpLogs != null && Inner.HttpLogs.FileSystem != null && (bool) Inner.HttpLogs.FileSystem.Enabled)
238+
if (Inner.HttpLogs != null && Inner.HttpLogs.FileSystem != null && Inner.HttpLogs.FileSystem.Enabled.HasValue && Inner.HttpLogs.FileSystem.Enabled.Value)
239239
{
240240
Inner.HttpLogs.FileSystem.RetentionInDays = retentionDays;
241241
}
242-
if (Inner.HttpLogs != null && Inner.HttpLogs.AzureBlobStorage != null && (bool)Inner.HttpLogs.AzureBlobStorage.Enabled)
242+
if (Inner.HttpLogs != null && Inner.HttpLogs.AzureBlobStorage != null && Inner.HttpLogs.AzureBlobStorage.Enabled.HasValue && Inner.HttpLogs.AzureBlobStorage.Enabled.Value)
243243
{
244244
Inner.HttpLogs.AzureBlobStorage.RetentionInDays = retentionDays;
245245
}
@@ -305,11 +305,11 @@ public WebAppDiagnosticLogsImpl<FluentT, FluentImplT, DefAfterRegionT, DefAfterG
305305
///GENMHASH:0AA703FD4D7171D9DD761057420590D4:57E8D27F0D0112D8FDF8632C55262083
306306
public WebAppDiagnosticLogsImpl<FluentT, FluentImplT, DefAfterRegionT, DefAfterGroupT, UpdateT> WithUnlimitedLogRetentionDays()
307307
{
308-
if (Inner.HttpLogs != null && Inner.HttpLogs.FileSystem != null && (bool) Inner.HttpLogs.FileSystem.Enabled)
308+
if (Inner.HttpLogs != null && Inner.HttpLogs.FileSystem != null && Inner.HttpLogs.FileSystem.Enabled.HasValue && Inner.HttpLogs.FileSystem.Enabled.Value)
309309
{
310310
Inner.HttpLogs.FileSystem.RetentionInDays = 0;
311311
}
312-
if (Inner.HttpLogs != null && Inner.HttpLogs.AzureBlobStorage != null && (bool) Inner.HttpLogs.FileSystem.Enabled)
312+
if (Inner.HttpLogs != null && Inner.HttpLogs.AzureBlobStorage != null && Inner.HttpLogs.FileSystem.Enabled.HasValue && Inner.HttpLogs.FileSystem.Enabled.Value)
313313
{
314314
Inner.HttpLogs.AzureBlobStorage.RetentionInDays = 0;
315315
}
@@ -319,7 +319,7 @@ public WebAppDiagnosticLogsImpl<FluentT, FluentImplT, DefAfterRegionT, DefAfterG
319319
///GENMHASH:6779E4B38BCBB810944CA68774B310C3:072E24F1A9FC72304BBE1ED245652D70
320320
public WebAppDiagnosticLogsImpl<FluentT, FluentImplT, DefAfterRegionT, DefAfterGroupT, UpdateT> WithWebServerFileSystemQuotaInMB(int quotaInMB)
321321
{
322-
if (Inner.HttpLogs != null && Inner.HttpLogs.FileSystem != null && (bool) Inner.HttpLogs.FileSystem.Enabled)
322+
if (Inner.HttpLogs != null && Inner.HttpLogs.FileSystem != null && Inner.HttpLogs.FileSystem.Enabled.HasValue && Inner.HttpLogs.FileSystem.Enabled.Value)
323323
{
324324
Inner.HttpLogs.FileSystem.RetentionInMb = quotaInMB;
325325
}

src/ResourceManagement/AppService/WebAppSourceControlImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ internal WebAppSourceControlImpl(
8888
{
8989
return null;
9090
}
91-
return (bool) Inner.IsMercurial ? Fluent.RepositoryType.Mercurial : Fluent.RepositoryType.Git;
91+
return (Inner.IsMercurial.HasValue && Inner.IsMercurial .Value) ? Fluent.RepositoryType.Mercurial : Fluent.RepositoryType.Git;
9292
}
9393

9494
///GENMHASH:AF58AEB1DD43D38B7FEDF266F4F40886:63F15AB00FF6315055DD4FFBCA6BE2EC

src/ResourceManagement/CosmosDB/CosmosDBAccountImpl.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public partial class CosmosDBAccountImpl :
3434
private IList<Microsoft.Azure.Management.CosmosDB.Fluent.Models.FailoverPolicyInner> failoverPolicies;
3535
private bool hasFailoverPolicyChanges;
3636
private const int maxDelayDueToMissingFailovers = 5000 * 12 * 10;
37-
private Dictionary<string,Models.VirtualNetworkRule> virtualNetworkRulesMap;
37+
private Dictionary<string,List<Models.VirtualNetworkRule>> virtualNetworkRulesMap;
3838

3939
public CosmosDBAccountImpl WithReadReplication(Region region)
4040
{
@@ -108,7 +108,7 @@ private Models.DatabaseAccountCreateUpdateParametersInner CreateUpdateParameters
108108
createUpdateParametersInner.IsVirtualNetworkFilterEnabled = inner.IsVirtualNetworkFilterEnabled;
109109
if (virtualNetworkRulesMap != null)
110110
{
111-
createUpdateParametersInner.VirtualNetworkRules = virtualNetworkRulesMap.Values.ToList();
111+
createUpdateParametersInner.VirtualNetworkRules = virtualNetworkRulesMap.Values.SelectMany(l => l).ToList();
112112
virtualNetworkRulesMap = null;
113113
}
114114
this.AddLocationsForCreateUpdateParameters(createUpdateParametersInner, this.failoverPolicies);
@@ -470,7 +470,12 @@ public CosmosDBAccountImpl WithVirtualNetwork(string virtualNetworkId, string su
470470
{
471471
this.Inner.IsVirtualNetworkFilterEnabled = true;
472472
string vnetId = virtualNetworkId + "/subnets/" + subnetName;
473-
EnsureVirtualNetworkRules().Add(vnetId, new VirtualNetworkRule() { Id = vnetId });
473+
var internalMap = EnsureVirtualNetworkRules();
474+
if(!internalMap.ContainsKey(vnetId))
475+
{
476+
internalMap.Add(vnetId, new List<VirtualNetworkRule>());
477+
}
478+
internalMap[vnetId].Add(new VirtualNetworkRule() { Id = vnetId });
474479
return this;
475480
}
476481

@@ -488,7 +493,11 @@ public CosmosDBAccountImpl WithVirtualNetworkRules(IList<Models.VirtualNetworkRu
488493
this.Inner.IsVirtualNetworkFilterEnabled = true;
489494
foreach (var vnetRule in virtualNetworkRules)
490495
{
491-
this.virtualNetworkRulesMap.Add(vnetRule.Id, vnetRule);
496+
if(!this.virtualNetworkRulesMap.ContainsKey(vnetRule.Id))
497+
{
498+
this.virtualNetworkRulesMap.Add(vnetRule.Id, new List<VirtualNetworkRule>());
499+
}
500+
this.virtualNetworkRulesMap[vnetRule.Id].Add(vnetRule);
492501
}
493502
}
494503
return this;
@@ -514,16 +523,20 @@ public CosmosDBAccountImpl WithoutVirtualNetwork(string virtualNetworkId, string
514523
}
515524

516525
///GENMHASH:9DD08936D3B4E402E37AEF19676FBBE5:B75CF3B3BDA8D4D5A2337A51BF9E22A0
517-
private Dictionary<string,Models.VirtualNetworkRule> EnsureVirtualNetworkRules()
526+
private Dictionary<string, List<Models.VirtualNetworkRule>> EnsureVirtualNetworkRules()
518527
{
519528
if (this.virtualNetworkRulesMap == null)
520529
{
521-
this.virtualNetworkRulesMap = new Dictionary<string, VirtualNetworkRule>();
530+
this.virtualNetworkRulesMap = new Dictionary<string, List<VirtualNetworkRule>>();
522531
if (this.Inner != null && this.Inner.VirtualNetworkRules != null)
523532
{
524533
foreach (var item in this.Inner.VirtualNetworkRules)
525534
{
526-
this.virtualNetworkRulesMap.Add(item.Id, item);
535+
if(!this.virtualNetworkRulesMap.ContainsKey(item.Id))
536+
{
537+
this.virtualNetworkRulesMap.Add(item.Id, new List<VirtualNetworkRule>());
538+
}
539+
this.virtualNetworkRulesMap[item.Id].Add(item);
527540
}
528541
}
529542
}

src/ResourceManagement/ResourceManager/Microsoft.Azure.Management.ResourceManager.Fluent.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.3.4" />
18+
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.3.6" />
1919
</ItemGroup>
2020

2121
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.4' ">

0 commit comments

Comments
 (0)