PUT https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}?api-version=2020-05-01
{
"properties": {
"amount": 5000,
"startDate": "2019-12-30T21:26:47.997Z",
"endDate": "2020-12-30T21:26:47.997Z"
}
}
import com.azure.resourcemanager.billing.fluent.models.InstructionInner;
import java.time.OffsetDateTime;
/** Samples for Instructions Put. */
public final class Main {
/*
* x-ms-original-file: specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/PutInstruction.json
*/
/**
* Sample code: PutInstruction.
*
* @param manager Entry point to BillingManager.
*/
public static void putInstruction(com.azure.resourcemanager.billing.BillingManager manager) {
manager
.instructions()
.putWithResponse(
"{billingAccountName}",
"{billingProfileName}",
"{instructionName}",
new InstructionInner()
.withAmount(5000f)
.withStartDate(OffsetDateTime.parse("2019-12-30T21:26:47.997Z"))
.withEndDate(OffsetDateTime.parse("2020-12-30T21:26:47.997Z")),
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.billing import BillingManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-billing
# USAGE
python put_instruction.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = BillingManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.instructions.put(
billing_account_name="{billingAccountName}",
billing_profile_name="{billingProfileName}",
instruction_name="{instructionName}",
parameters={
"properties": {
"amount": 5000,
"endDate": "2020-12-30T21:26:47.997Z",
"startDate": "2019-12-30T21:26:47.997Z",
}
},
)
print(response)
# x-ms-original-file: specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/PutInstruction.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armbilling_test
import (
"context"
"log"
"time"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/billing/armbilling"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/PutInstruction.json
func ExampleInstructionsClient_Put() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armbilling.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewInstructionsClient().Put(ctx, "{billingAccountName}", "{billingProfileName}", "{instructionName}", armbilling.Instruction{
Properties: &armbilling.InstructionProperties{
Amount: to.Ptr[float32](5000),
EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-30T21:26:47.997Z"); return t }()),
StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-30T21:26:47.997Z"); return t }()),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Instruction = armbilling.Instruction{
// Name: to.Ptr("{instructionName}"),
// Type: to.Ptr("Microsoft.Billing/billingAccounts/billingProfiles/instructions"),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}"),
// Properties: &armbilling.InstructionProperties{
// Amount: to.Ptr[float32](5000),
// EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-30T21:26:47.997Z"); return t}()),
// StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-30T21:26:47.997Z"); return t}()),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { BillingManagementClient } = require("@azure/arm-billing");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Creates or updates an instruction. These are custom billing instructions and are only applicable for certain customers.
*
* @summary Creates or updates an instruction. These are custom billing instructions and are only applicable for certain customers.
* x-ms-original-file: specification/billing/resource-manager/Microsoft.Billing/stable/2020-05-01/examples/PutInstruction.json
*/
async function putInstruction() {
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const billingAccountName = "{billingAccountName}";
const billingProfileName = "{billingProfileName}";
const instructionName = "{instructionName}";
const parameters = {
amount: 5000,
endDate: new Date("2020-12-30T21:26:47.997Z"),
startDate: new Date("2019-12-30T21:26:47.997Z"),
};
const credential = new DefaultAzureCredential();
const client = new BillingManagementClient(credential, subscriptionId);
const result = await client.instructions.put(
billingAccountName,
billingProfileName,
instructionName,
parameters
);
console.log(result);
}
putInstruction().catch(console.error);
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue