Skip to content

Fixing bug in Set-AzureSBAuthorizationRule cmdlet #2111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.0.1-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.ServiceBus, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\WindowsAzure.ServiceBus.2.3.2.0\lib\net40-full\Microsoft.ServiceBus.dll</HintPath>
<Reference Include="Microsoft.ServiceBus">
<HintPath>..\..\..\packages\WindowsAzure.ServiceBus.2.8.2\lib\net40-full\Microsoft.ServiceBus.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -384,7 +384,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="packages.config" />
<None Include="Performance\Microsoft.ServiceBus.MessagingPerformanceCounters.man" />
<None Include="Profile\SelectAzureSubscriptionTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<package id="Moq" version="4.2.1510.2205" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="System.Spatial" version="5.6.4" targetFramework="net45" />
<package id="WindowsAzure.ServiceBus" version="2.3.2.0" targetFramework="net45" />
<package id="WindowsAzure.ServiceBus" version="2.8.2" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="6.1.0" targetFramework="net45" />
<package id="xunit" version="2.1.0" targetFramework="net45" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.0.1-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.ServiceBus, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\WindowsAzure.ServiceBus.2.3.2.0\lib\net40-full\Microsoft.ServiceBus.dll</HintPath>
<Reference Include="Microsoft.ServiceBus, Version=2.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\WindowsAzure.ServiceBus.2.8.2\lib\net40-full\Microsoft.ServiceBus.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,16 @@ public ServiceBusClientExtensions()
/// Creates new instance from ServiceBusClientExtensions
/// </summary>
/// <param name="subscription"></param>
public ServiceBusClientExtensions(AzureSMProfile profile, AzureSubscription subscription)
public ServiceBusClientExtensions(AzureSMProfile profile)
{
subscriptionId = subscription.Id.ToString();
Subscription = subscription;
ServiceBusClient = AzureSession.ClientFactory.CreateClient<ServiceBusManagementClient>(profile, subscription, AzureEnvironment.Endpoint.ServiceManagement);
if (profile.Context.Subscription == null)
{
throw new ArgumentException(Resources.InvalidDefaultSubscription);
}

subscriptionId = profile.Context.Subscription.Id.ToString();
Subscription = profile.Context.Subscription;
ServiceBusClient = AzureSession.ClientFactory.CreateClient<ServiceBusManagementClient>(profile, profile.Context.Subscription, AzureEnvironment.Endpoint.ServiceManagement);
}

/// <summary>
Expand Down Expand Up @@ -838,7 +843,7 @@ public virtual bool NamespaceExists(string name)
return GetNamespace().Exists(ns => ns.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
}

public virtual ExtendedServiceBusNamespace CreateNamespace(string name, string location, NamespaceType type, bool createACSNamespace = true)
public virtual ExtendedServiceBusNamespace CreateNamespace(string name, string location, NamespaceType type, bool createACSNamespace = false)
{
location = string.IsNullOrEmpty(location) ? GetDefaultLocation() : location;

Expand Down Expand Up @@ -936,7 +941,9 @@ static public SharedAccessAuthorizationRule ToSharedAccessAuthorizationRule(
rights.Add(AccessRights.Send);
}

return new SharedAccessAuthorizationRule(sbRule.KeyName, sbRule.PrimaryKey, sbRule.SecondaryKey, rights);
var sasRule = new SharedAccessAuthorizationRule(sbRule.KeyName, sbRule.PrimaryKey, sbRule.SecondaryKey, rights);
sasRule.Revision = sbRule.Revision;
return sasRule;
}

static public ServiceBusConnectionDetail ToServiceBusConnectionDetail(this ServiceBusNamespaceDescription namespaceDesc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
<package id="Microsoft.WindowsAzure.Management.WebSites" version="4.5.0-prerelease" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="System.Spatial" version="5.6.4" targetFramework="net45" />
<package id="WindowsAzure.ServiceBus" version="2.3.2.0" targetFramework="net45" />
<package id="WindowsAzure.ServiceBus" version="2.8.2" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="6.1.0" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public override void ExecuteCmdlet()
}
else
{
ServiceBusClient = ServiceBusClient ?? new ServiceBusClientExtensions(Profile, Profile.Context.Subscription);
ServiceBusClient = ServiceBusClient ?? new ServiceBusClientExtensions(Profile);
IsServiceBusNamespaceAvailable(Profile.Context.Subscription.Id.ToString(), Name);
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/ServiceManagement/Services/Commands/Commands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.0.1-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.ServiceBus, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\WindowsAzure.ServiceBus.2.3.2.0\lib\net40-full\Microsoft.ServiceBus.dll</HintPath>
<Reference Include="Microsoft.ServiceBus, Version=2.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\WindowsAzure.ServiceBus.2.8.2\lib\net40-full\Microsoft.ServiceBus.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand All @@ -114,6 +114,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\Microsoft.Web.Deployment.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.2.0.0.0\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -336,7 +339,6 @@
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="Performance\Microsoft.ServiceBus.MessagingPerformanceCounters.man" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Common\Commands.Common.Authentication\Commands.Common.Authentication.csproj">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class GetAzureSBAuthorizationRuleCommand : AzureSMCmdlet

public override void ExecuteCmdlet()
{
Client = Client ?? new ServiceBusClientExtensions(Profile, Profile.Context.Subscription);
Client = Client ?? new ServiceBusClientExtensions(Profile);
List<ExtendedAuthorizationRule> rules = null;
List<PSObject> output = new List<PSObject>();
AuthorizationRuleFilterOption options = new AuthorizationRuleFilterOption()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class GetAzureSBLocationCommand : AzureSMCmdlet
/// </summary>
public override void ExecuteCmdlet()
{
Client = Client ?? new ServiceBusClientExtensions(Profile, Profile.Context.Subscription);
Client = Client ?? new ServiceBusClientExtensions(Profile);
WriteObject(Client.GetServiceBusRegions(), true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class GetAzureSBNamespaceCommand : AzureSMCmdlet
/// </summary>
public override void ExecuteCmdlet()
{
Client = Client ?? new ServiceBusClientExtensions(Profile, Profile.Context.Subscription);
Client = Client ?? new ServiceBusClientExtensions(Profile);

if (string.IsNullOrEmpty(Name))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class NewAzureSBAuthorizationRuleCommand : AzureSMCmdlet

public override void ExecuteCmdlet()
{
Client = Client ?? new ServiceBusClientExtensions(Profile, Profile.Context.Subscription);
Client = Client ?? new ServiceBusClientExtensions(Profile);
ExtendedAuthorizationRule rule = null;
PSObject output = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class NewAzureSBNamespaceCommand : AzureSMCmdlet
/// </summary>
public override void ExecuteCmdlet()
{
Client = Client ?? new ServiceBusClientExtensions(Profile, Profile.Context.Subscription);
Client = Client ?? new ServiceBusClientExtensions(Profile);
if (CreateACSNamespace.HasValue)
{
WriteObject(Client.CreateNamespace(Name, Location, NamespaceType, CreateACSNamespace.Value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class RemoveAzureSBAuthorizationRuleCommand : AzureSMCmdlet

public override void ExecuteCmdlet()
{
Client = Client ?? new ServiceBusClientExtensions(Profile, Profile.Context.Subscription);
Client = Client ?? new ServiceBusClientExtensions(Profile);
AuthorizationRuleFilterOption options = new AuthorizationRuleFilterOption()
{
Namespace = Namespace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public override void ExecuteCmdlet()
Name,
() =>
{
Client = Client ?? new ServiceBusClientExtensions(Profile, Profile.Context.Subscription);
Client = Client ?? new ServiceBusClientExtensions(Profile);
Client.RemoveNamespace(Name);

if (PassThru)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class SetAzureSBAuthorizationRuleCommand : AzureSMCmdlet

public override void ExecuteCmdlet()
{
Client = Client ?? new ServiceBusClientExtensions(Profile, Profile.Context.Subscription);
Client = Client ?? new ServiceBusClientExtensions(Profile);
ExtendedAuthorizationRule rule = null;
PSObject output = null;

Expand Down
3 changes: 2 additions & 1 deletion src/ServiceManagement/Services/Commands/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.0.1-preview" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.0.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="12.6.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.MediaServices" version="4.0.0" targetFramework="net45" />
Expand All @@ -26,5 +27,5 @@
<package id="Microsoft.WindowsAzure.Management.WebSites" version="4.5.0-prerelease" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="System.Spatial" version="5.6.4" targetFramework="net45" />
<package id="WindowsAzure.ServiceBus" version="2.3.2.0" targetFramework="net45" />
<package id="WindowsAzure.ServiceBus" version="2.8.2" targetFramework="net45" />
</packages>