Skip to content

New version of cmdlets for AzureRM.Billing and AzureRM.Consumption #3852

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

Closed
wants to merge 8 commits into from
Closed
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
2 changes: 1 addition & 1 deletion AzurePowershell.Test.targets
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
<XUnitTests Include=".\src\ResourceManager\Billing\Commands.Billing.Test\bin\Debug\Microsoft.Azure.Commands.Billing.Test.dll"/>
<XUnitTests Include=".\src\ResourceManager\Cdn\Commands.Cdn.Test\bin\Debug\Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.dll"/>
<XUnitTests Include=".\src\ResourceManager\CognitiveServices\CognitiveServices.Test\bin\Debug\Microsoft.Azure.Commands.Management.CognitiveServices.Test.dll"/>
<XUnitTests Include=".\src\ResourceManager\ContainerRegistry\Commands.ContainerRegistry.Test\bin\Debug\Microsoft.Azure.Commands.ContainerRegistry.Test.dll"/>
<XUnitTests Include=".\src\ResourceManager\Compute\Commands.Compute.Test\bin\Debug\Microsoft.Azure.Commands.Compute.Test.dll"/>
<XUnitTests Include=".\src\ResourceManager\Consumption\Commands.Consumption.Test\bin\Debug\Microsoft.Azure.Commands.Consumption.Test.dll"/>
<XUnitTests Include=".\src\ResourceManager\DataFactories\Commands.DataFactories.Test\bin\Debug\Microsoft.Azure.Commands.DataFactories.Test.dll"/>
<XUnitTests Include=".\src\ResourceManager\DataLakeAnalytics\Commands.DataLakeAnalytics.Test\bin\Debug\Microsoft.Azure.Commands.DataLakeAnalytics.Test.dll"/>
<XUnitTests Include=".\src\ResourceManager\DataLakeStore\Commands.DataLakeStore.Test\bin\Debug\Microsoft.Azure.Commands.DataLake.Test.dll"/>
Expand Down
188 changes: 68 additions & 120 deletions setup/azurecmdfiles.wxi

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/ResourceManager/Billing/AzureRM.Billing.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '2.8.0'; }
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()
FormatsToProcess = '.\Microsoft.Azure.Commands.Billing.Format.ps1xml'

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @('.\Microsoft.Azure.Commands.Billing.dll')
Expand All @@ -72,7 +72,8 @@ NestedModules = @('.\Microsoft.Azure.Commands.Billing.dll')
FunctionsToExport = @()

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = 'Get-AzureRmBillingInvoice'
CmdletsToExport = 'Get-AzureRmBillingInvoice',
'Get-AzureRmBillingPeriod'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
5 changes: 5 additions & 0 deletions src/ResourceManager/Billing/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
- Additional information about change #1
-->
## Current Release
* New Cmdlet Get-AzureRmBillingPeriod
- cmdlet to retrieve azure billing periods of the subscription.
* Update Cmdlet Get-AzureRmBillingInvoice
- new property BillingPeriodNames
- output in list view

## Version 0.11.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Billing, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Billing.1.0.0-preview\lib\net45\Microsoft.Azure.Management.Billing.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.Azure.Management.Billing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Billing.2.0.0-preview\lib\net452\Microsoft.Azure.Management.Billing.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand All @@ -86,8 +85,7 @@
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.5\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
<Private>True</Private>
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.6\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.5\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
Expand All @@ -112,6 +110,9 @@
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -137,18 +138,37 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScenarioTests\BillingPeriodsTests.cs" />
<Compile Include="ScenarioTests\InvoicesTests.cs" />
<Compile Include="ScenarioTests\TestController.cs" />
</ItemGroup>
<ItemGroup>
<None Include="MSSharedLibKey.snk" />
<None Include="packages.config" />
<None Include="ScenarioTests\BillingPeriodsTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\InvoicesTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Billing.Test.ScenarioTests.BillingPeriodsTests\TestGetBillingPeriodWithName.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Billing.Test.ScenarioTests.BillingPeriodsTests\TestGetBillingPeriodWithNames.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Billing.Test.ScenarioTests.BillingPeriodsTests\TestListBillingPeriods.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Billing.Test.ScenarioTests.BillingPeriodsTests\TestListBillingPeriodsWithMaxCount.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Billing.Test.ScenarioTests.InvoicesTests\TestGetInvoiceWithName.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Billing.Test.ScenarioTests.InvoicesTests\TestGetInvoiceWithNames.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Billing.Test.ScenarioTests.InvoicesTests\TestGetLatestInvoice.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Billing.Test.ScenarioTests.ScenarioTest;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.Billing.Test.ScenarioTests
{
public class BillingPeriodsTests
{
private ServiceManagemenet.Common.Models.XunitTracingInterceptor _logger;

public BillingPeriodsTests(Xunit.Abstractions.ITestOutputHelper output)
{
_logger = new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output);
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestListBillingPeriods()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ListBillingPeriods");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestListBillingPeriodsWithMaxCount()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-ListBillingPeriodsWithMaxCount");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetBillingPeriodWithName()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetBillingPeriodWithName");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetBillingPeriodWithNames()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetBillingPeriodWithNames");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
List billing periods
#>
function Test-ListBillingPeriods
{
$billingBillingPeriods = Get-AzureRmBillingPeriod

Assert-True {$billingBillingPeriods.Count -ge 1}
Assert-NotNull $billingBillingPeriods[0].Name
Assert-NotNull $billingBillingPeriods[0].Id
Assert-NotNull $billingBillingPeriods[0].Type
Assert-NotNull $billingBillingPeriods[0].BillingPeriodStartDate
Assert-NotNull $billingBillingPeriods[0].BillingPeriodEndDate
}

<#
.SYNOPSIS
List billing periods with MaxCount
#>
function Test-ListBillingPeriodsWithMaxCount
{
$billingBillingPeriods = Get-AzureRmBillingPeriod -MaxCount 1

Assert-True {$billingBillingPeriods.Count -eq 1}
Assert-NotNull $billingBillingPeriods[0].Name
Assert-NotNull $billingBillingPeriods[0].Id
Assert-NotNull $billingBillingPeriods[0].Type
Assert-NotNull $billingBillingPeriods[0].BillingPeriodStartDate
Assert-NotNull $billingBillingPeriods[0].BillingPeriodEndDate
}

<#
.SYNOPSIS
Get billing period with specified name
#>
function Test-GetBillingPeriodWithName
{
$billingPeriodName = "201705-1"
$billingPeriod = Get-AzureRmBillingPeriod -Name $billingPeriodName

Assert-AreEqual $billingPeriodName $billingPeriod.Name
Assert-NotNull $billingPeriod.Id
Assert-NotNull $billingPeriod.Type
Assert-NotNull $billingPeriod.BillingPeriodStartDate
Assert-NotNull $billingPeriod.BillingPeriodEndDate
Assert-NotNull $billingPeriod.InvoiceNames
Assert-AreEqual 1 $billingPeriod.InvoiceNames.Count
Assert-AreEqual "201705-217994100075389" $billingPeriod.InvoiceNames
}

<#
.SYNOPSIS
Get billing period with specified names
#>
function Test-GetBillingPeriodWithNames
{
$billingPeriodNames = "201705-1", "201704-1", "201703-1"
$billingBillingPeriods = Get-AzureRmBillingPeriod -Name $billingPeriodNames

Assert-True {$billingBillingPeriods.Count -eq 3}
Foreach($billingPeriod in $billingBillingPeriods)
{
Assert-NotNull $billingPeriod.Id
Assert-NotNull $billingPeriod.Type
Assert-NotNull $billingPeriod.BillingPeriodStartDate
Assert-NotNull $billingPeriod.BillingPeriodEndDate
Assert-NotNull $billingPeriod.InvoiceNames
Assert-AreEqual 1 $billingPeriod.InvoiceNames.Count
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,12 @@ public void TestGetInvoiceWithName()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetInvoiceWithName");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetInvoiceWithNames()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetInvoiceWithNames");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Get invoice with specified name
#>
function Test-GetInvoiceWithName
{
$invoiceName = "2017-02-09-117646100066812"
$invoiceName = "201705-217994100075389"
$invoice = Get-AzureRmBillingInvoice -Name $invoiceName

Assert-AreEqual $invoiceName $invoice.Name
Expand All @@ -99,4 +99,30 @@ function Test-GetInvoiceWithName
Assert-NotNull $invoice.InvoicePeriodEndDate
Assert-NotNull $invoice.DownloadUrl
Assert-NotNull $invoice.DownloadUrlExpiry
Assert-NotNull $invoice.BillingPeriodNames
Assert-AreEqual 1 $invoice.BillingPeriodNames.Count
Assert-AreEqual "201705-1" $invoice.BillingPeriodNames
}

<#
.SYNOPSIS
Get invoice with specified names
#>
function Test-GetInvoiceWithNames
{
$invoiceNames = "201705-217994100075389", "201704-117049130068772", "201703-117646100066812"
$billingInvoices = Get-AzureRmBillingInvoice -Name $invoiceNames

Assert-True {$billingInvoices.Count -eq 3}
Foreach($invoice in $billingInvoices)
{
Assert-NotNull $invoice.Id
Assert-NotNull $invoice.Type
Assert-NotNull $invoice.InvoicePeriodStartDate
Assert-NotNull $invoice.InvoicePeriodEndDate
Assert-NotNull $invoice.DownloadUrl
Assert-NotNull $invoice.DownloadUrlExpiry
Assert-NotNull $invoice.BillingPeriodNames
Assert-AreEqual 1 $invoice.BillingPeriodNames.Count
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class TestController : RMTestBase

public AuthorizationManagementClient AuthorizationManagementClient { get; private set; }

public BillingClient BillingManagementClient { get; private set; }
public BillingManagementClient BillingManagementClient { get; private set; }

public static TestController NewInstance
{
Expand Down Expand Up @@ -177,9 +177,9 @@ private GalleryClient GetGalleryClient()
return TestBase.GetServiceClient<GalleryClient>(_csmTestFactory);
}

private BillingClient GetBillingManagementClient(MockContext context)
private BillingManagementClient GetBillingManagementClient(MockContext context)
{
return context.GetServiceClient<BillingClient>(TestEnvironmentFactory.GetTestEnvironment());
return context.GetServiceClient<BillingManagementClient>(TestEnvironmentFactory.GetTestEnvironment());
}
}
}
Loading