Git Product home page Git Product logo

azure-rest-api-specs-examples's Introduction

Azure SDK examples for azure-rest-api-specs

This repository is the collection of Azure SDK examples corresponding to REST API examples from Azure REST API Specifications.

Involved SDK repositories:

The repository is maintained by automated pipeline.

Specification on filename

Mapping rule of filename from examples from azure-rest-api-specs to azure-rest-api-specs-examples.

  1. Replace /examples/ with language specific folder of /examples-<language>/.
    • Metadata: The JSON file as metadata.
    • Code snippet: Replace .json with .<language-ext> in file extension.

Currently supported language includes:

  • go for Go
  • java for Java
  • js for JavaScript
  • js-rlc for JavaScript RLC
  • python for Python
  • dotnet for .NET
  • az for Azure CLI

Pending:

  • ts for typescript

An instance of the mapping

For instance, JSON example in azure-rest-api-specs with filename

specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlows_Create.json

would map to code snippet (language=java) with filename

specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples-java/DataFlows_Create.java

and metadata with filename

specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples-java/DataFlows_Create.json

in azure-rest-api-specs-examples.

File content

Code snippet

Code snippet is runnable code in SDK language, as the SDK example.

Currently supported language-ext includes:

  • go for Go
  • java for Java
  • js for JavaScript (includes RLC)
  • py for Python
  • cs for .NET
  • az for Azure CLI

Pending:

  • ts for typescript

Metadata

Metadata is a JSON that contains information related to the code snippet.


Property Type Required Description
sdkUrl string no The URL to SDK documentation. It usually provides information on package and authentication.
description string no The description of the example.

Cause of missing SDK examples

It is possible that for some api-version in some resource provider, there is no corresponding SDK example file, for some language. Typical reason is that either the SDK of that language is not released, or the released SDK does not generate examples.

There is also possibility of missing a few SDK examples in a release. Typical reason could be that SDK specifically removed a portion of the APIs, or the JSON example is considered not correct (e.g. some required parameter/property is not provided in JSON).

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

azure-rest-api-specs-examples's People

Contributors

azure-fluent avatar azure-sdk avatar jsntcy avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar ronniegeraghty avatar weidongxu-microsoft avatar xboxeer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-rest-api-specs-examples's Issues

Get role assignment by ID Example Go code does not work

Link to sample

https://learn.microsoft.com/en-us/rest/api/authorization/role-assignments/get-by-id?tabs=Go

Library name and version

github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v2 v2.1.1

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

The Get role assignment by ID example code does not work. As any request using a valid role assignment ID returns in an HTTP 404 response. The strange thing is that it seems to work if I pass in a valid role definition ID (/providers/Microsoft.Authorization/roleDefinitions/<role-definition-ID>).

Does not work

res, err := clientFactory.NewRoleAssignmentsClient().GetByID(ctx, "/subscriptions/<retracted-SubscriptionID>/providers/Microsoft.Authorization/roleAssignments/<retracted-ID>", &armauthorization.RoleAssignmentsClientGetByIDOptions{TenantID: nil})

This works:

res, err := clientFactory.NewRoleAssignmentsClient().GetByID(ctx, "/subscriptions/<retracted-SubscriptionID>/providers/Microsoft.Authorization/roleDefinitions/<retracted-ID>", &armauthorization.RoleAssignmentsClientGetByIDOptions{TenantID: nil})

Expected behavior

I expect to receive an HTTP 200 response, and not a 404.

Actual behavior

Failed to finish the request  GET https://management.azure.com/subscriptions/<retracted-SubscriptionID>/providers/Microsoft.Authorization/roleAssignments/<retracted-ID>
--------------------------------------------------------------------------------
RESPONSE 404: 404 Not Found
ERROR CODE: RoleAssignmentNotFound
--------------------------------------------------------------------------------
{
  "error": {
    "code": "RoleAssignmentNotFound",
    "message": "The role assignment '<retracted-ID>' is not found."
  }
}

Reproduction Steps

Run the Go example code using any role assignment ID

Environment

github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v2 v2.1.1
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2

[Sample Issue dotnet] TablesListByWorkspace encounters System.InvalidOperationException

Link to sample

https://learn.microsoft.com/en-us/rest/api/loganalytics/tables/list-by-workspace?view=rest-loganalytics-2022-10-01&tabs=dotnet

Library name and version

Azure.ResourceManager.OperationalInsights 1.2.0

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

When running the sample, I receive the following exception when calling collection.GetAllAsync():

System.InvalidOperationException: 'The requested operation requires an element of type 'String', but the target element has type 'True'.'

It seems to happen here:

// File: Models\OperationalInsightsTableData.Serialization.cs

if (property0.NameEquals("retentionInDaysAsDefault"u8))
{
    if (property0.Value.ValueKind == JsonValueKind.Null)
    {
        property0.ThrowNonNullablePropertyIsNull();
        continue;
    }
   // Exception thrown here
    retentionInDaysAsDefault = new RetentionInDaysAsDefaultState(property0.Value.GetString());
    continue;
}

If I try to do the following:

// This table exists. Same exception.
var table = collection.Get("AACAudit");

// This table does not exist. No exception thrown.
var table = collection.Get("madeuptable");

Expected behavior

I would expect the call to successfully complete without throwing an exception.

Actual behavior

The call always throws an exception even when using different log analytic workspaces that I have access to.

Reproduction Steps

Run the sample with a valid subscriptionId, resourceGroupId, and workspace name.

Environment

.NET SDK:
Version: 7.0.306
Commit: f500069cb7

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win10-x64

Host:
Version: 7.0.14
Architecture: x64
Commit: 808851b07a

[Sample Issue] Output format is wrong

Link to sample

https://learn.microsoft.com/en-us/rest/api/billing/invoices/list-by-billing-profile?view=rest-billing-2020-05-01&tabs=Python

Library name and version

azure.mgmt.billing 6.0.0

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

I run this code:

from azure.mgmt.billing import BillingManagementClient
from azure.identity import ClientSecretCredential

credentials = ClientSecretCredential(
    tenant_id="<TenantID>",
    client_id="<ClientID>",
    client_secret="<ClientSecret>",
    api_version="2020-05-01"
)

client = BillingManagementClient(
    credential=credentials,
    subscription_id='<SubscriptionID>',
)

response = client.invoices.list_by_billing_profile(
    billing_account_name="<BillingAccount>",
    billing_profile_name="<BillingProfile>",
    period_start_date="2024-02-01",
    period_end_date="2024-02-29",
)
for item in response:
    print(item)

I don't get an invoice in return.

Expected behavior

An invoice description in JSON format.

Actual behavior

The sample code give me this output:

{'additional_properties': {}, 'id': '/providers/Microsoft.Billing/billingAccounts/<BillingAccount>/invoices/<Invoice>', 'name': 'G040589327', 'type': 'Microsoft.Billing/billingAccounts/invoices', 'due_date': datetime.datetime(2024,
    4,
    4,
    6,
    7,
    13,
    95965, tzinfo=<isodate.tzinfo.Utc object at 0x000002FE9EEEB050>), 'invoice_date': datetime.datetime(2024,
    3,
    5,
    6,
    7,
    13,
    95965, tzinfo=<isodate.tzinfo.Utc object at 0x000002FE9EEEB050>), 'status': 'Due', 'amount_due': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE779D0>, 'azure_prepayment_applied': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE77A50>, 'billed_amount': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE77E50>, 'credit_amount': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE77E90>, 'free_azure_credit_applied': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE77AD0>, 'sub_total': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE77ED0>, 'tax_amount': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE77F90>, 'total_amount': <azure.mgmt.billing.models._models_py3.Amount object at 0x000002FE9FE77F50>, 'invoice_period_start_date': datetime.datetime(2024,
    2,
    1,
    0,
    0, tzinfo=<isodate.tzinfo.Utc object at 0x000002FE9EEEB050>), 'invoice_period_end_date': datetime.datetime(2024,
    2,
    29,
    23,
    59,
    59,
    999999, tzinfo=<isodate.tzinfo.Utc object at 0x000002FE9EEEB050>), 'invoice_type': None, 'is_monthly_invoice': True, 'billing_profile_id': '/providers/Microsoft.Billing/billingAccounts/<BillingAccount>/billingProfiles/<BillingProfile>', 'billing_profile_display_name': 'Formpipe Software Ltd', 'purchase_order_number': '', 'documents': [<azure.mgmt.billing.models._models_py3.Document object at 0x000002FEA11940D0>
    ], 'payments': [], 'rebill_details': None, 'document_type': 'Invoice', 'billed_document_id': None, 'credit_for_document_id': None, 'subscription_id': None
}

If I change to

for item in response:
    print(item.serialize())

I get this output:
{}

Reproduction Steps

Run the example.

Environment

Windows 11
Python 3.11.2

"Billing Accounts - List" returns empty list for api version 2020-05-01

Link to sample

https://learn.microsoft.com/en-us/rest/api/billing/billing-accounts/list?view=rest-billing-2020-05-01&viewFallbackFrom=rest-billing-2021-10-01

Library name and version

com.azure.resourcemanager:azure-resourcemanager-billing:1.0.0-beta.3

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

Getting empty billing account list when using api version 2020-05-01, both using REST and the billing sdk.

Able to retrieve account list using version 2019-10-01-preview.

Expected behavior

Expecting to get billing account list when using sdk method and\or HTTP endpoint

Actual behavior

Getting empty billing account list

Reproduction Steps

TokenCredential credential = new ClientSecretCredentialBuilder().clientId(credentials.getClientId())
                                                                            .clientSecret(credentials.getClientSecret())
                                                                            .tenantId(credentials.getTenantId())
                                                                            .build();

            AzureProfile profile = new AzureProfile(credentials.getTenantId(), null, AzureEnvironment.AZURE);

            BillingManager billingManager = BillingManager.authenticate(credential, profile);

            retVal = billingManager.billingAccounts().list().stream().collect(Collectors.toList());

Environment

Java 8 dropwizard

not able to fetch private endpoint properties

Link to sample

https://learn.microsoft.com/en-us/rest/api/virtualnetwork/private-endpoints/get?view=rest-virtualnetwork-2023-09-01&tabs=Python#get-private-endpoint

Library name and version

https://learn.microsoft.com/en-us/rest/api/virtualnetwork/private-endpoints/get?view=rest-virtualnetwork-2023-09-01&tabs=Python#get-private-endpoint

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

response = client.private_endpoints.get()
should return the properties field as well but this is return empty dict {}

Goal: i need to fetch resourceGuid for private endpoint which im not able to

Expected behavior

No response

Actual behavior

No response

Reproduction Steps

No response

Environment

No response

Invalid URI: The format of the URI could not be determined

Link to sample

https://learn.microsoft.com/en-us/rest/api/datafactory/integration-runtimes/get-status?tabs=dotnet&tryIt=true&source=docs#code-try-0

Library name and version

Azure.ResourceManager.DataFactory 1.0.0-beta.2

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

The issue arises when I try to query the status of an integration runtime in azure data factory. See link for the code sample used.
The offending line of code seems to be
IntegrationRuntimeStatusResult result = await factoryIntegrationRuntime.GetStatusAsync();

I used an azure function to test the code and deployed the function to azure

Expected behavior

The code sample returns the status of the specified integration runtime without throwing an error.

Actual behavior

The code sample throws an error. See error below

Invalid URI: The format of the URI could not be determined. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString)
at Azure.ResourceManager.DataFactory.Models.SelfHostedIntegrationRuntimeStatus.DeserializeSelfHostedIntegrationRuntimeStatus(JsonElement element)
at Azure.ResourceManager.DataFactory.Models.IntegrationRuntimeStatus.DeserializeIntegrationRuntimeStatus(JsonElement element)
at Azure.ResourceManager.DataFactory.Models.IntegrationRuntimeStatusResult.DeserializeIntegrationRuntimeStatusResult(JsonElement element)
at Azure.ResourceManager.DataFactory.IntegrationRuntimesRestOperations.GetStatusAsync(String subscriptionId, String resourceGroupName, String factoryName, String integrationRuntimeName, CancellationToken cancellationToken)
at Azure.ResourceManager.DataFactory.FactoryIntegrationRuntimeResource.GetStatusAsync(CancellationToken cancellationToken)

Reproduction Steps

Replace code sample variables with valid subscriptionId ,resourceGroupName ,factoryName and integrationRuntimeName .
Run the code sample to retrieve the integration runtime status.

Environment

Deployed to a function app using windows
IDE Visual Studio 17.0

List users for a static site is giving an permission error

Link to sample

No response

Library name and version

"@azure/arm-appservice": "^13.0.3" and "@azure/identity": "^3.1.3"

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

I'm trying to get this sample code to work in my Static Web App function: https://learn.microsoft.com/en-us/rest/api/appservice/static-sites/list-static-site-users?tabs=JavaScript

It seems to respond correctly, but instead of giving the list of users it gives me two different errors:

  • AggregateAuthenticationError
  • CredentialUnavailableError

What am I missing here? I can run the code just fine locally and get a list of users. But when I deploy my app I'm getting these errors.

Expected behavior

Get a list of static web app users.

Actual behavior

Getting an error messages:

  • AggregateAuthenticationError
  • CredentialUnavailableError

Reproduction Steps

Just copy paste the code in example, deploy it and try to run it.

Environment

No response

Python examples in the documentation don't work

Link to sample

https://learn.microsoft.com/en-us/rest/api/advisor/recommendations/list?tabs=Python

Library name and version

API Version: 2020-01-01

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

When I run the Python example in the reference for this API, it returns a scope error.
https://learn.microsoft.com/en-us/rest/api/advisor/recommendations/list?tabs=Python

The environment variables (AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET) and subscriptions are set and running.
Any other information on the configuration required to register an application?

C:\Users\user1\source\repos\ListRecommendations\ListRecommendations>python ListRecommendations.py
Traceback (most recent call last):
File "C:\Users\user1\source\repos\ListRecommendations\ListRecommendations\ListRecommendations.py", line 32, in <module>
main()
File "C:\Users\user1\source\repos\ListRecommendations\ListRecommendations\ListRecommendations.py", line 26, in main
for item in response:
File "C:\Users\user1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\azure\core\paging.py", line 132, in __next__
return next(self._page_iterator)
File "C:\Users\user1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\azure\core\paging.py", line 76, in __next__
self._response = self._get_next(self.continuation_token)
File "C:\Users\user1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\azure\mgmt\advisor\operations\_recommendations_operations.py", line 231, in get_next
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
azure.core.exceptions.HttpResponseError: (AuthorizationFailed) The client 'xxxx-xxxx' with object id 'xxxx-xxxx' does not have authorization to perform action 'Microsoft.Advisor/recommendations/read' over scope '/subscriptions/xxxx-xxxx' or the scope is invalid. If access was recently granted, please refresh your credentials.
Code: AuthorizationFailed
Message: The client 'xxxx-xxxx' with object id 'xxxx-xxxx' does not have authorization to perform action 'Microsoft.Advisor/recommendations/read' over scope '/subscriptions/xxxx-xxxx' or the scope is invalid. If access was recently granted, please refresh your credentials.

Expected behavior

I hope that like a "Sample Response" in the documents.

Actual behavior

I write above "Details", I got error.

Reproduction Steps

  1. I register "App registrations" in the Azure AD blade of Azure Portal.
  2. I set the following settings:
  3. I set The environment variables (AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET) and subscriptions in sample code of python from above app of App registrations
  4. Run python code

Environment

Python 3.8
PowerShell 7.2

[Java Sample Issue]

Library name and version

azure-storage-file-share 12.8.2

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

No example code

Expected behavior

No response

Actual behavior

No response

Reproduction Steps

No response

Environment

Java version

[Sample Issue] Workspace Purge

Link to sample

https://learn.microsoft.com/en-us/rest/api/loganalytics/workspace-purge/purge?tabs=dotnet

Library name and version

Azure.ResourceManager.OperationalInsights 1.1.0

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

The samples are assigning filter values using BinaryData.FromString, this usage is incorrect and causes serialisation errors. The code summary for the Value field on OperationalInsightsWorkspacePurgeFilter explains the usage correctly and BinaryData.FromObjectAsJson should be used in these examples.

Expected behavior

Expected behaviour is that the code sample would work when replacing values and updating the filter.

Actual behavior

Actual behaviour is that the code sample errors with a serialisation error due to incorrect usage.

Reproduction Steps

Use the code snippet as is, with the example filter of

new()
{
    Column = "_ResourceId",
    Operator = "==",
    Value = BinaryData.FromString("/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/SomeResourceGroup/providers/microsoft.insights/components/AppInsightResource"),
}

This will result in the serialisation error '/' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.

Environment

Windows 11
Visual Studio 2022
dotnet 6

Unable to update multiple diagnostic setting categories

Link to sample

https://learn.microsoft.com/en-us/rest/api/monitor/diagnostic-settings/create-or-update?tabs=dotnet

Library name and version

Azure.ResourceManager.Monitor

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

I want to update multiple diagnostic setting categories using DiagnosticSettingData class. Right now it is only possible to update one category at a time whereas using the Management API (Microsoft.Insights/diagnosticSettings/{name}) I can update multiple categories at a time.

"logs": [
{
"category": "StorageRead",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
},
{
"category": "StorageWrite",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
] - This is possible through API

Logs =
{
new LogSettings(true)
{
CategoryGroup = "allLogs",
RetentionPolicy = new RetentionPolicy(false,0),
}
} - Through SDK I can only set one category

Did anyone in the community come across the same issue and has a solution?

Expected behavior

No response

Actual behavior

No response

Reproduction Steps

No response

Environment

No response

[Sample Issue] Regenrating Log Analytics Workspace Access Keys requires a parameter that isn't documented.

Link to sample

https://learn.microsoft.com/en-us/rest/api/loganalytics/shared-keys/regenerate?view=rest-loganalytics-2023-09-01&tabs=Python#regeneratesharedkeys

Library name and version

azure-mgmt-loganalytics 12.0.0

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

Hey there,

The REST API documented on the linked page is missing a required parameter. The sample in its current form results in the error keyType value must equal primarySharedKey or secondarySharedKey. Some experimentation shows that this key-value-pair should be passed as a query parameter.

The error in the API documentation also affects libraries generated from it, e.g. azure-mgmt-loganalytics version 12.0.0. The library has no way to pass this parameter, so we are forced to use direct HTTP calls with an undocumented parameter instead of using the appropriate function in the management library.

Thanks a bunch,
Kjeld

Expected behavior

I should be able to pass a parameter to define which key to regenerate into LogAnalyticsManagementClient.shared_keys.regenerate.

This should then result in that one key being regenerated.

Actual behavior

I cannot pass a key specifier into LogAnalyticsManagementClient.shared_keys.regenerate.

The call results in a failed request with the error keyType value must equal primarySharedKey or secondarySharedKey.

Reproduction Steps

Follow this sample request

i.e., create a Log Analytics Workspace, get a LogAnalyticsManagementClient and attempt to call client.shared_keys.regenerate with the appropriate Workspace details as parameters.

Environment

Library: azure-mgmt-loganalytics
Library version: 12.0.0
OS: Windows 10
Python Version: 3.11.8

[Sample Issue]

Link to sample

https://github.com/Azure/azure-sdk-for-python/blob/azure-mgmt-subscription_3.2.0b1/sdk/subscription/azure-mgmt-subscription/generated_samples/rename_subscription.py

Library name and version

azure-mgmt-subscription

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

https://github.com/Azure/azure-sdk-for-python/blob/azure-mgmt-subscription_3.2.0b1/sdk/subscription/azure-mgmt-subscription/generated_samples/rename_subscription.py

subscription.rename is not present

Expected behavior

No response

Actual behavior

No response

Reproduction Steps

No response

Environment

No response

[Sample Issue]

Link to sample

https://github.com/Azure/azure-sdk-for-js/blob/%40azure/arm-reservations_9.0.0/sdk/reservations/arm-reservations/samples-dev/reservationListAllSample.ts

Library name and version

azure/[email protected]

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

by having a skipToken = 50 in the default examlpe many testing the code will find themselves with an empty result set. Lower it to 0 in the default example would ensure that everyone will get an result of there is anything to find. Afterwards people can start tweaking it for their needs.

Expected behavior

SMB users will expect to see entries in their first test of the example code.

Actual behavior

Many will get an empty result set.

Reproduction Steps

Runs this against any tenant that hasn't 50 non archived Reserved Instances.

Environment

N/A

[Sample Issue]

Link to sample

https://learn.microsoft.com/en-us/rest/api/container-instances/container-groups/list?view=rest-container-instances-2023-05-01&tabs=JavaScript

Library name and version

@azure/arm-containerinstance

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

not getting actual enough response that i need

"containers": [
{
"name": "demo1",
"properties": {
"command": [],
"environmentVariables": [],
"image": "nginx",
"instanceView": {
"restartCount": 0,
"currentState": {
"state": "Running",
"startTime": "2017-10-17T17:27:21Z",
"detailStatus": ""
},
// other res
]``

Expected behavior

{
"value": [
{
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"location": "WestUs",
"zones": [
"1"
],
"name": "demo1",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"command": [],
"environmentVariables": [],
"image": "nginx",
"instanceView": {
"restartCount": 0,
"currentState": {
"state": "Running",
"startTime": "2017-10-17T17:27:21Z",
"detailStatus": ""
},
"events": []
},
"ports": [
{
"port": 80
}
],
"resources": {
"requests": {
"cpu": 1,
"memoryInGB": 1.5
}
},
"volumeMounts": [
{
"mountPath": "/mnt/volume1",
"name": "volume1",
"readOnly": false
}
]
}
}
],
"imageRegistryCredentials": [
{
"server": "azcloudconsoleregistry.azurecr.io",
"username": "azcloudconsoleregistry"
}
],
"ipAddress": {
"ip": "10.0.0.1",
"ports": [
{
"port": 80,
"protocol": "TCP"
}
],
"type": "Public"
},
"osType": "Linux",
"provisioningState": "Succeeded",
"volumes": [
{
"azureFile": {
"readOnly": false,
"shareName": "share1",
"storageAccountName": "storage1"
},
"name": "volume1"
}
]
},
"type": "Microsoft.ContainerInstance/containerGroups"
}
]
}``

Actual behavior

{"id":"/subscriptions/__/resourceGroups/__/providers/Microsoft.ContainerInstance/containerGroups/aci-fat-substantial-butcher","name":"aci-fat-substantial-butcher","type":"Microsoft.ContainerInstance/containerGroups","location":"__","provisioningState":"Succeeded","containers":[{"name":"fat-substantial-butcher","image":"__","ports":[],"environmentVariables":[],"resources":{"requests":{"memoryInGB":1.5,"cpu":1}}}],"imageRegistryCredentials":[],"restartPolicy":"Never","osType":"Linux","sku":"Standard","initContainers":[]}

Reproduction Steps

const aciInstances = new Array();
for await (let item of aciClient.containerGroups.list()) {
aciInstances.push(item);
}
console.log(aciInstances);

Environment

Node.js 20 lts

[Sample Issue] It appears the example Python script is not working

Link to sample

No response

Library name and version

Python

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

The script provided on this page (https://learn.microsoft.com/en-us/rest/api/trafficmanager/endpoints/update?tabs=Python) for Python is not working. It was tested by a customer and not successful. The customer provided a sample of code that is working for them.

`from azure.identity import DefaultAzureCredential
from azure.mgmt.trafficmanagerimport TrafficManagerManagementClient

def update_tm_endpoint(target: str):
subscription_id = "subscription_id"
resource_group_name = "rg-name"
profile_name = "trafficmanager-profile-name"
endpoint_type = "azureEndpoints"
endpoint_name = "trafficmanagerendpointname"
target = "/subscriptions/subscription_id/resourceGroups/rg-name/providers/Microsoft.Web/sites/website-name"
weight = "1"
endpoint_status = "Enabled"
credentials = DefaultAzureCredential()
traffic_manager_client = TrafficManagerManagementClient(
credentials, subscription_id
)
endpoint = traffic_manager_client.endpoints.get(
resource_group_name, profile_name, endpoint_type, endpoint_name
)
endpoint.target_resource_id = target
endpoint.weight = weight
endpoint.endpoint_status = endpoint_status
res = traffic_manager_client.endpoints.create_or_update(
resource_group_name, profile_name, endpoint_type, endpoint_name, endpoint
)
return res, datetime.now()`

Expected behavior

No response

Actual behavior

No response

Reproduction Steps

No response

Environment

No response

Unable to specify a weekly recurring schedule for Global Schedules

Link to sample

https://learn.microsoft.com/en-us/rest/api/dtl/global-schedules/create-or-update?view=rest-dtl-2018-09-15&tabs=HTTP

Library name and version

Rest API (management.azure.com) 2018-09-15

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

Currently it doesn't seem possible to specify a Global Schedule with a weekly recurrence. Daily works fine, but providing the weekly recurrence details results in an HTTP400 response that mentions the daily recurrence is missing.
Sample that produces the error:

PUT https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.DevTestLab/schedules/shutdown-computevm-mycoolvm?api-version=2018-09-15

body:

{ "location": "canadacentral", "properties": { "status": "Enabled", "timeZoneId": "Hawaiian Standard Time", "taskType": "ComputeVmShutdownTask", "targetResourceId": "/subscriptions/<REDACTED SUB>/resourceGroups/<REDACTED RG>/providers/Microsoft.Compute/virtualMachines/mycoolvm", "weeklyRecurrence": { "time": "0700", "weekdays": [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ] } } }

The response
{ "error": { "code": "MissingRequiredProperty", "message": "Missing required property 'DailyRecurrence'." } }

even if you specify the properties.dailyRecurrence value as such:

PUT https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.DevTestLab/schedules/shutdown-computevm-mycoolvm?api-version=2018-09-15

body:
{ "location": "canadacentral", "properties": { "status": "Enabled", "timeZoneId": "Hawaiian Standard Time", "taskType": "ComputeVmShutdownTask", "targetResourceId": "/subscriptions/<REDACTED SUB>/resourceGroups/<REDACTED RG>/providers/Microsoft.Compute/virtualMachines/mycoolvm", "dailyRecurrence": { "time": "0700" }, "weeklyRecurrence": { "time": "0700", "weekdays": [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ] } } }

The following HTTP 400 is returned:

{ "error": { "code": "ConflictingProperties", "message": "Input only one of the properties among [WeeklyRecurrence, DailyRecurrence, HourlyRecurrence]. Entering more than one will cause a conflict." } }

I can confirm that it works if you wish to specify only a daily schedule but there is no way that I can get it to add a weekly schedule

Expected behavior

I would expect an HTTP 201 or 200 with a sample response similar to the example in the documentation:

{ "properties": { "status": "Enabled", "taskType": "ComputeVmShutdownTask", "weeklyRecurrence": { "weekdays": [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" ], "time": "0700" }, "timeZoneId": "Hawaiian Standard Time", "notificationSettings": { "status": "Disabled", "timeInMinutes": 0 }, "createdDate": "2020-12-29T22:54:54.9335182+00:00", "provisioningState": "Succeeded", "uniqueIdentifier": "{id}" }, "id": "/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/schedules/labvmautostart", "name": "LabVmAutoStart", "type": "microsoft.devtestlab/labs/schedules", "location": "{location}", "tags": { "tagName1": "tagValue1" } }

Actual behavior

An HTTP 400 is returned when only a weekly recurrence is specified:

{ "error": { "code": "MissingRequiredProperty", "message": "Missing required property 'DailyRecurrence'." } }

Reproduction Steps

  1. follow the link to the MS documentation here:
  2. https://learn.microsoft.com/en-us/rest/api/dtl/global-schedules/create-or-update?view=rest-dtl-2018-09-15&tabs=HTTP#code-try-0
  3. Sign in with your Azure Account that has a valid subscription.
  4. Create a virtual machine
  5. Fill in the request required form details and provide a request body that specifies a weekly recurrence schedule. Be sure to set taskType as a "ComputeVmShutdownTask":

{ "location": "canadacentral", "properties": { "status": "Enabled", "timeZoneId": "Hawaiian Standard Time", "taskType": "ComputeVmShutdownTask", "targetResourceId": "/subscriptions/<REDACTED SUB>/resourceGroups/<REDACTED RG>/providers/Microsoft.Compute/virtualMachines/mycoolvm", "dailyRecurrence": { "time": "0700" }, "weeklyRecurrence": { "time": "0700", "weekdays": [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ] } } }

Environment

No response

API rerun trigger is giving the Invalid trigger type: ScheduleTrigger when i run the Scheduled triggers is there any restriction on schedule trigger

Link to sample

https://learn.microsoft.com/en-us/rest/api/datafactory/trigger-runs/rerun?view=rest-datafactory-2018-06-01&tabs=Python#code-try-0

Library name and version

2018-06-01

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

when i do rerun of trigger through post man with following API , i get reponse as below:
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/triggers/{triggerName}/triggerRuns/{runId}/rerun?api-version=2018-06-01

Reponse:
{
"error": {
"code": "BadRequest",
"message": "Invalid trigger type: ScheduleTrigger",
"target": "TestTrigger",
"details": null
}
}

Expected behavior

No response

Actual behavior

No response

Reproduction Steps

No response

Environment

No response

502 Bad Gate Way issues

Link to sample

https://learn.microsoft.com/zh-cn/rest/api/aks/managed-clusters/abort-latest-operation?tabs=HTTP

Library name and version

azure-mgmt-containerservice 26.0.0

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

Hi team,
Why it is report me 502 Bad GateWay error, while I use agent pool and manager cluster begin_abort_latest_operation method? When I request using the rest API, when it is an update, the error code reported to me for the first request. If I request again, he will report me that the current status is' cancel 'and' operation not allowed '.
Python SDK request code:

client.managed_clusters.begin_abort_latest_operation(resource_group_name=self.resource_group,
resource_name=self.cluster_name)

client.agent_pools.begin_abort_latest_operation(self.resource_group, self.cluster_name, nodepool_name)

API request details:
POST: /subscriptions/af8a838e-eb6b-4a7a-974e-36128b1ea4b7/resourceGroups/cqfybg6fef-sapsecxco2-d7/providers/Microsoft.ContainerService/managedclusters/cqfybg6fef-sapsecxco2-d7-kub/abort?api-version=2023-07-01
POST: /subscriptions/af8a838e-eb6b-4a7a-974e-36128b1ea4b7/resourceGroups/cqfybg6fef-sapsecxco2-d7/providers/Microsoft.ContainerService/managedClusters/cqfybg6fef-sapsecxco2-d7-kub/agentPools/shrvsbzqv9/abort?api-version=2021-09-01
BR
Marvin,Wen

Expected behavior

No response

Actual behavior

No response

Reproduction Steps

No response

Environment

No response

Latest available armeventgrid SDK for Golang does not contain NewCaCertificatesClient

Link to sample

https://learn.microsoft.com/en-us/rest/api/eventgrid/controlplane-version2023-06-01-preview/ca-certificates/create-or-update?tabs=Go

Library name and version

github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventgrid/armeventgrid/v2 v2.1.1

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

The sample for uploading a CA Certificate to Event Grid Namespace shows to use the NewCaCertificatesClient() function. That function doesn't seem to exist in the latest (2.1.1) version of armeventgrid. From the linked source code (https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/resourcemanager/eventgrid/armeventgrid/client_factory.go) it appears to exist, but in 2.2.0-beta.1 version, which is not published or publicly available, and therefore unable to upload a certificate.

Expected behavior

Function to exist in latest package

Actual behavior

Function is undefined in latest package

Reproduction Steps

  1. go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventgrid/armeventgrid/v2
  2. Copy and paste sample
  3. go build

Environment

Windows 11, go1.18.2, vs code

[Sample Issue]

Link to sample

https://learn.microsoft.com/en-us/rest/api/virtualnetwork/network-security-groups/list?tabs=Python&tryIt=true&source=docs#code-try-0

Library name and version

Python 3.7+ . https://aka.ms/azsdk/python/all

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

Python is output is not expected. it's not in Json format. getting in below format -

{'additional_properties': {}, 'id': '/subscriptions/xxxxxxxxx-xxxx-xxxxx-xxxx-xxxxxxxx/resourceGroups/xx-xxxx-xxx/providers/Microsoft.Network/networkSecurityGroups/xxxxx-nsg', 'name': 'xxxxxx-nsg', 'type': 'Microsoft.Network/networkSecurityGroups', 'location': 'CentralUS', 'tags': None, 'etag': 'W/"xxxxx-5a47-xxxxx-a6da-xxxxxxx"', 'flush_connection': None, 'security_rules': [<azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C2890>, <azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C2A10>, <azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C2B90>, <azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C2D10>, <azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C2E90>, <azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C3050>, <azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C31D0>, <azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C3350>, <azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C34D0>], 'default_security_rules': [<azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C3650>, <azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C37D0>, <azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C3950>, <azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C3AD0>, <azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C3C50>, <azure.mgmt.network.models._models.SecurityRule object at 0x000001DC2D4C3E10>], 'network_interfaces': None, 'subnets': None, 'flow_logs': [<azure.mgmt.network.models._models.FlowLog object at 0x000001DC2D4C3ED0>], 'resource_guid': 'xxxx4308-xxxx-40b5-xxxx-af9652xxxxxx', 'provisioning_state': 'Succeeded'}

Expected behavior

it should be in Json Format - refer sample response for python.

https://learn.microsoft.com/en-us/rest/api/virtualnetwork/network-security-groups/list?tabs=Python&tryIt=true&source=docs#code-try-0

Actual behavior

No response

Reproduction Steps

No response

Environment

No response

[Sample Issue] Failed to create VirtualMachineScalesetextension with exception Value cannot be null. (Parameter 'id')

Link to sample

https://github.com/Azure/azure-rest-api-specs-examples/blob/e5d9625122924e4f53a94c8037b5b915a682054b/specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2022-03-01/examples-dotnet/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtensions_CreateOrUpdate_MinimumSet_Gen.cs

Library name and version

Azure.ResourceManager.Compute 1.0.1

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

Exception:
Value cannot be null. (Parameter 'id')

at Azure.ResourceManager.ArmResource..ctor(ArmClient client, ResourceIdentifier id)
at Azure.ResourceManager.Compute.VirtualMachineScaleSetExtensionResource..ctor(ArmClient client, ResourceIdentifier id)
at Azure.ResourceManager.Compute.VirtualMachineScaleSetExtensionOperationSource.Azure.Core.IOperationSource<Azure.ResourceManager.Compute.VirtualMachineScaleSetExtensionResource>.CreateResult(Response response, CancellationToken cancellationToken)
at Azure.Core.NextLinkOperationImplementation.OperationToOperationOfT1.<UpdateStateAsync>d__3.MoveNext() at System.Threading.Tasks.ValueTask1.get_Result()
at Azure.Core.OperationInternal1.<UpdateStatusAsync>d__20.MoveNext() at Azure.Core.OperationPoller.<WaitForCompletionAsync>d__11.MoveNext() at Azure.Core.OperationInternalBase.<WaitForCompletionResponseAsync>d__19.MoveNext() at Azure.Core.OperationInternal1.d__19.MoveNext()
at Azure.ResourceManager.Compute.VirtualMachineScaleSetExtensionCollection.CreateOrUpdate(WaitUntil waitUntil, String vmssExtensionName, VirtualMachineScaleSetExtensionData data, CancellationToken cancellationToken)
at ASCRemediatorFunction.Remediations.VmssRemediations.InstallLogAnalyticsAgentExtensionOnWindows(ArmClient armClient, OmsWorkSpaceProperties ascWorkSpace, String resourceId, ILogger log) in C:\Data\SourceCode\AzDO\ASCAutomation\ASCRemediatorFunction\Remediations\VmssRemediations.cs:line 49

Expected behavior

The extension should be created successfully.

Actual behavior

Failed to create extension with exception.

Reproduction Steps

VirtualMachineScaleSetExtensionData vmssExtensionData = new VirtualMachineScaleSetExtensionData("ExtensionName");
ArmOperation vmssExtensionResource = ssExtensionCollection.CreateOrUpdate(Azure.WaitUntil.Completed, vmssExtensionData.Name, vmssExtensionData);

Environment

.NET SDK:
Version: 7.0.102
Commit: 4bbdd14480

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19044
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.102\

Host:
Version: 7.0.2
Architecture: x64
Commit: d037e070eb

.NET SDKs installed:
6.0.308 [C:\Program Files\dotnet\sdk]
7.0.102 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

IDE: Visual Studio 2022

Message: The Resource 'Microsoft.DBforPostgreSQL/servers/test3-pg-dbe40df75' under resource group 'test3-spokec3775245' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix[Sample Issue]

Link to sample

https://learn.microsoft.com/en-us/rest/api/postgresql/flexibleserver/servers/restart?tabs=Python

Library name and version

azure.mgmt.rdbms

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

Message: The Resource 'Microsoft.DBforPostgreSQL/servers/test3-pg-dbe40df75' under resource group 'test3-spokec3775245' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix

Expected behavior

it should also connect to the type Microsoft.DBforPostgreSQL/flexibleservers/dbname

Actual behavior

its unable to find the type Microsoft.DBforPostgreSQL/flexibleservers/dbname

Reproduction Steps

No response

Environment

linux

[Sample Issue]

Link to sample

https://learn.microsoft.com/en-us/rest/api/backup/backup-jobs/list?tabs=JavaScript#list-jobs-with-time-filter

Library name and version

@azure/arm-recoveryservicesbackup 11.0.0

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

The filter example provided does not filter the data. I have tried this on my Azure environment and I always get back all JobResource records regardless of the date filter I provide.

Expected behavior

The list of JobResource records filtered by date.

Actual behavior

All records are returned.

Reproduction Steps

Run sample with dates correct for your environment.

Environment

Node 18.15.0
OSX 14.0

[Sample Issue]

Link to sample

No response

Library name and version

https://learn.microsoft.com/en-us/rest/api/automation/software-update-configurations/create?tabs=dotnet

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

ResourceType coming null, unable to create SoftwareUpdateConfiguration.

Expected behavior

Resourcetype namespace and type value should not be null, or provide option how to set these values.an

Actual behavior

unable to set Resourcetype namespace and type value and create is failing.

Reproduction Steps

Resourcetype coming null.

Environment

window 10, Visual studio 2022

TenantResource.GetReservationOrders() not working for hybrid benefit reservation

Link to sample

https://learn.microsoft.com/en-us/rest/api/reserved-vm-instances/reservation/list?tabs=dotnet

Library name and version

Azure.ResourceManager.Reservations (1.3.0)

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

  1. Outer loop -> GetReservationOrders: App gets all reservation orders, does some filtering
var orderCollection = tenantResource.GetReservationOrders().GetAllAsync();
await foreach (ReservationOrderResource orderResource in orderCollection)
{
   .......
}

=> working as expected.
2) Then, Inner loop: For all ReservationOrders returned , app gets all ReservationDetails

var reservationDetailCollection = orderResource.GetReservationDetails();
await foreach (ReservationDetailResource reservationDetailResource in reservationDetailCollection.GetAllAsync())
{
.......
}

=> working as expected for all ReservationOrders EXCEPT reservation is a Hybrid Benefit reservation. In this case an exception is thrown

Expected behavior

GetReservationDetails() working for all types of reservation

Actual behavior

If a reservation order is a hybrid benefit reservation an exception is thrown:

"Exception":"System.ArgumentException: Value cannot be an empty string. (Parameter 'resourceId')
   at Azure.Core.Argument.AssertNotNullOrEmpty(String value, String name)
   at Azure.Core.ResourceIdentifier..ctor(String resourceId)
   at Azure.ResourceManager.Reservations.Models.ReservationProperties.DeserializeReservationProperties(JsonElement element)
   at Azure.ResourceManager.Reservations.ReservationDetailData.DeserializeReservationDetailData(JsonElement element)
   at Azure.ResourceManager.Reservations.ReservationDetailCollection.<GetAllAsync>b__7_2(JsonElement e)
   at Azure.Core.PageableHelpers.PageableImplementation`1.GetAsyncEnumerator(CancellationToken cancellationToken)+MoveNext()
   at Azure.Core.PageableHelpers.PageableImplementation`1.GetAsyncEnumerator(CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at .... await foreach from inner loop above

** Note**: For all other reservations (78) everything works as expected => looks like deserializing this type of reservation fails

Reproduction Steps

For obvious reasons i cannot share credentials for TenantResource here..
But problem can be reproduced by using example code and only change:
Guid reservationOrderId = Guid.Parse("276e7ae4-84d0-4da6-ab4b-d6b94f3557da");
with a reservation order Guid that references a hybrid benefit reservation resource.

Environment

Linux Container on AKS
.NET Core 6.0 LTS
Visual Studio CE 2022, 17.6.5

Resource Health Events List by Tenant Id 403 Forbidden

Link to sample

https://learn.microsoft.com/en-us/rest/api/resourcehealth/events/list-by-tenant-id?view=rest-resourcehealth-2022-10-01&tabs=JavaScript#listeventsbytenantid

Library name and version

@azure/arm-resourcehealth, @azure/identity

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

Node app when accessing service health events List by Tenant Id, get 403 forbidden error
https://management.azure.com/providers/Microsoft.ResourceHealth/events

image

Has the following configured:

  • access using AzureDefaultCredential with AZURE_CLIENT_ID, AZURE_TENANT_ID and AZURE_CLIENT_SECRET exist in env vars.
  • registered App is assigned with tenant role: "Global Admin" and "Security Admin"
  • registered App is assigned with custom role at management group with all "MicrosoftResourceHealth" permissions
  • registered App has granted "Azure Service Management - user_impersonation" scope
{ "error": { "code": "AuthorizationFailed", "message": "The client '06bc32ab-5ab5-4b8d-9f6c-95d0a420eb95' with object id '06bc32ab-5ab5-4b8d-9f6c-95d0a420eb95' does not have authorization to perform action 'Microsoft.ResourceHealth/events/read' over scope '/providers/Microsoft.ResourceHealth' or the scope is invalid. If access was recently granted, please refresh your credentials." } } ![image](https://github.com/Azure/azure-rest-api-specs-examples/assets/43234101/8fcce67b-7be1-4526-a68b-79a2d4b1152f)

Expected behavior

expects a successful response with HTTP code 200

Actual behavior

API responded 403 forbidden

{
"error": {
"code": "AuthorizationFailed",
"message": "The client '06bc32ab-5ab5-4b8d-9f6c-95d0a420eb95' with object id '06bc32ab-5ab5-4b8d-9f6c-95d0a420eb95' does not have authorization to perform action 'Microsoft.ResourceHealth/events/read' over scope '/providers/Microsoft.ResourceHealth' or the scope is invalid. If access was recently granted, please refresh your credentials."
}
}

Reproduction Steps

No response

Environment

Node 20.x
Windows 11

EventGridNamespaceClientResource Not found in Azure.ResourceManager.Resources;

Link to sample

https://learn.microsoft.com/en-us/rest/api/eventgrid/controlplane/clients/create-or-update?view=rest-eventgrid-controlplane-2023-12-15-preview&tabs=dotnet#examples

Library name and version

Azure.ResourceManager 1.11.0

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

ResourceIdentifier eventGridNamespaceClientResourceId = EventGridNamespaceClientResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, clientName);
EventGridNamespaceClientResource eventGridNamespaceClient = client.GetEventGridNamespaceClientResource(eventGridNamespaceClientResourceId);

// invoke the operation
EventGridNamespaceClientData data = new EventGridNamespaceClientData()
{
Description = "This is a test client",
ClientCertificateAuthentication = new ClientCertificateAuthentication()
{
ValidationScheme = ClientCertificateValidationScheme.SubjectMatchesAuthenticationName,
},
State = EventGridNamespaceClientState.Enabled,
Attributes =
{
["deviceTypes"] = BinaryData.FromObjectAsJson(new object[] { "Fan", "Light", "AC" }),
["floor"] = BinaryData.FromString(""3""),
["room"] = BinaryData.FromString(""345""),
},
};
ArmOperation lro = await eventGridNamespaceClient.UpdateAsync(WaitUntil.Completed, data);
EventGridNamespaceClientResource result = lro.Value;

// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
EventGridNamespaceClientData resourceData = result.Data;

Expected behavior

No response

Actual behavior

No response

Reproduction Steps

No response

Environment

No response

[Sample Issue] Python code not showing

Link to sample

https://learn.microsoft.com/en-us/rest/api/azureml/2022-10-01/compute/create-or-update?tabs=Python&source=docs#update-a-aml-compute

Library name and version

Compute - Create Or Update API-Version: 2022-10-01

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

Does not show

Expected behavior

No response

Actual behavior

No response

Reproduction Steps

No response

Environment

No response

sentinel_onboarding_states.create() fails with HTTPResponse Error - Bad Request

Link to sample

https://learn.microsoft.com/en-us/rest/api/securityinsights/preview/sentinel-onboarding-states/create?tabs=Python

Library name and version

azure-mgmt-securityinsight v1.0.0

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

Using the sample python code in the documentation to create a Microsoft Sentinel onboarding state on an existing workspace fails with a HTTPResponseError - Bad request. It seems to suggests a required property is missing from the request.

Expected behavior

An onboarding state is created on the workspace for Microsoft Sentinel

Actual behavior

Error returned

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/casey/source/sandbox/python-azure/.venv/lib/python3.9/site-packages/azure/core/tracing/decorator.py", line 78, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/Users/casey/source/sandbox/python-azure/.venv/lib/python3.9/site-packages/azure/mgmt/securityinsight/operations/_sentinel_onboarding_states_operations.py", line 344, in create
    raise HttpResponseError(response=response, error_format=ARMErrorFormat)
azure.core.exceptions.HttpResponseError: (BadRequest) A non-empty request body is required.
Code: BadRequest
Message: A non-empty request body is required.

Reproduction Steps

  1. Install dependencies:
  • pip install azure-mgmt-securityinsight azure-identity
  1. Execute sample code

Environment

  • Macbook Air M1 running MacOS Ventura 13.1
  • Python: 3.9.6
> pip show azure-mgmt-securityinsight
Name: azure-mgmt-securityinsight
Version: 1.0.0
Summary: Microsoft Azure Security Insight Management Client Library for Python
Home-page: https://github.com/Azure/azure-sdk-for-python
Author: Microsoft Corporation
Author-email: [email protected]
License: MIT License
Location: /Users/casey/.pyenv/versions/3.10.2/lib/python3.10/site-packages
Requires: azure-common, azure-mgmt-core, msrest
Required-by: 
> pip show azure-identity
Name: azure-identity
Version: 1.12.0
Summary: Microsoft Azure Identity Library for Python
Home-page: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity
Author: Microsoft Corporation
Author-email: [email protected]
License: MIT License
Location: /Users/casey/.pyenv/versions/3.10.2/lib/python3.10/site-packages
Requires: azure-core, cryptography, msal, msal-extensions, six
Required-by: 

Reader role does not have access to call NewBackupStatusClient().Get

Link to sample

https://learn.microsoft.com/en-us/rest/api/backup/backup-status/get?view=rest-backup-2023-02-01&tabs=Go

Library name and version

armrecoveryservicesbackup/v2

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

RBAC Reader role does not have access to call NewBackupStatusClient().Get. Backup Reader role works.

Expected behavior

Reader role should contain all other reader roles

Actual behavior

NewBackupStatusClient().Get returns RESPONSE 403: 403 Forbidden ERROR CODE: AuthorizationFailed when accessed using a service principal with Reader role

Reproduction Steps

Run the example code with a service principal with Reader role

Environment

Multiple environments

unable to connect to postgres flexible server

Link to sample

https://learn.microsoft.com/en-us/rest/api/postgresql/flexibleserver/servers/restart?tabs=Python

Library name and version

azure.mgmt.rdbms

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

cannot import name 'PostgreSQLManagementClient' from 'azure.mgmt.rdbms'

Expected behavior

it should import the package

Actual behavior

cannot import name 'PostgreSQLManagementClient' from 'azure.mgmt.rdbms'

Reproduction Steps

No response

Environment

linux

Scrapy the azure-rest-api-specs to calculate operation level sample coverage

We need one more level down of our sample coverage, from RP to Operation level, what we have now is

  1. API Operations in rest api swagger
  2. API Operation examples in rest api swagger operation x-ms-examples field
  3. A list of samples we collected in this repo and their corresponding language

What we want to achieve
We'd like to know that for every rest api operation, if they have x-ms-examples, they should have corresponding language's sample
The final data should be represented in a power bi report

Deploy a site from a zipped package not working

Link to sample

https://learn.microsoft.com/en-us/rest/api/appservice/static-sites/create-zip-deployment-for-static-site?tabs=JavaScript#deploy-a-site-from-a-zipped-package

Library name and version

@azure/arm-appservice 13.0.3

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

code sample

const { WebSiteManagementClient } = require("@azure/arm-appservice");
const { DefaultAzureCredential } = require("@azure/identity");

/**
 * This sample demonstrates how to Description for Deploys zipped content to a static site.
 *
 * @summary Description for Deploys zipped content to a static site.
 * x-ms-original-file: specification/web/resource-manager/Microsoft.Web/stable/2022-03-01/examples/StaticSiteZipDeploy.json
 */
async function deployASiteFromAZippedPackage() {
  const subscriptionId = ""; // made it empty for the issue
  const resourceGroupName = ""; // made it empty for the issue
  const name = "";
  const staticSiteZipDeploymentEnvelope = {
    appZipUrl: "myzipURL",
    deploymentTitle: "test",
    provider: "node",
  };
  const credential = new DefaultAzureCredential();
  console.log(credential);
  const client = new WebSiteManagementClient(credential, subscriptionId);
  const result =
    await client.staticSites.beginCreateZipDeploymentForStaticSiteAndWait(
      resourceGroupName,
      name,
      staticSiteZipDeploymentEnvelope
    );
  console.log(result);
}

deployASiteFromAZippedPackage().catch(console.error);

I get the below error while deploying.

  "name": "RestError",
  "statusCode": 501,
  "request": {
    "url": "https://management.azure.com/subscriptions/dbb23b75-1396-4368-aa95-aac40adcd8b4/resourceGroups/appshare/providers/Microsoft.Web/staticSites/test5/zipdeploy?api-version=2022-03-01",
    "headers": {
      "content-type": "application/json",
      "accept": "application/json",
      "accept-encoding": "gzip,deflate",
      "user-agent": "azsdk-js-arm-appservice/13.0.3 core-rest-pipeline/1.10.0 Node/v16.17.1 OS/(arm64-Darwin-22.2.0)",
      "x-ms-client-request-id": "89b18f48-1d12-4f4f-9ce8-2985a1e179e9",
      "authorization": "REDACTED",
      "content-length": "274"
    },
    "method": "POST",
    "timeout": 0,
    "disableKeepAlive": false,
    "streamResponseStatusCodes": {},
    "withCredentials": false,
    "requestId": "89b18f48-1d12-4f4f-9ce8-2985a1e179e9",
    "allowInsecureConnection": false,
    "enableBrowserStreams": false
  },
  "details": {
    "Code": "NotImplemented",
    "Message": "The requested method is not implemented.",
    "Target": null,
    "Details": [
      {
        "Message": "The requested method is not implemented."
      },
      {
        "Code": "NotImplemented"
      },
      {
        "ErrorEntity": {
          "ExtendedCode": "51009",
          "MessageTemplate": "The requested method is not implemented.",
          "Parameters": [],
          "Code": "NotImplemented",
          "Message": "The requested method is not implemented."
        }
      }
    ],
    "Innererror": null
  }

Expected behavior

It should deploy using the zip URL.

Actual behavior

giving this error

  "name": "RestError",
  "statusCode": 501,
  "request": {
    "url": "https://management.azure.com/subscriptions/dbb23b75-1396-4368-aa95-aac40adcd8b4/resourceGroups/appshare/providers/Microsoft.Web/staticSites/test5/zipdeploy?api-version=2022-03-01",
    "headers": {
      "content-type": "application/json",
      "accept": "application/json",
      "accept-encoding": "gzip,deflate",
      "user-agent": "azsdk-js-arm-appservice/13.0.3 core-rest-pipeline/1.10.0 Node/v16.17.1 OS/(arm64-Darwin-22.2.0)",
      "x-ms-client-request-id": "89b18f48-1d12-4f4f-9ce8-2985a1e179e9",
      "authorization": "REDACTED",
      "content-length": "274"
    },
    "method": "POST",
    "timeout": 0,
    "disableKeepAlive": false,
    "streamResponseStatusCodes": {},
    "withCredentials": false,
    "requestId": "89b18f48-1d12-4f4f-9ce8-2985a1e179e9",
    "allowInsecureConnection": false,
    "enableBrowserStreams": false
  },
  "details": {
    "Code": "NotImplemented",
    "Message": "The requested method is not implemented.",
    "Target": null,
    "Details": [
      {
        "Message": "The requested method is not implemented."
      },
      {
        "Code": "NotImplemented"
      },
      {
        "ErrorEntity": {
          "ExtendedCode": "51009",
          "MessageTemplate": "The requested method is not implemented.",
          "Parameters": [],
          "Code": "NotImplemented",
          "Message": "The requested method is not implemented."
        }
      }
    ],
    "Innererror": null
  }

Reproduction Steps

use below sample

const { WebSiteManagementClient } = require("@azure/arm-appservice");
const { DefaultAzureCredential } = require("@azure/identity");

/**
 * This sample demonstrates how to Description for Deploys zipped content to a static site.
 *
 * @summary Description for Deploys zipped content to a static site.
 * x-ms-original-file: specification/web/resource-manager/Microsoft.Web/stable/2022-03-01/examples/StaticSiteZipDeploy.json
 */
async function deployASiteFromAZippedPackage() {
  const subscriptionId = ""; // made it empty for the issue
  const resourceGroupName = ""; // made it empty for the issue
  const name = "";
  const staticSiteZipDeploymentEnvelope = {
    appZipUrl: "myzipURL",
    deploymentTitle: "test",
    provider: "node",
  };
  const credential = new DefaultAzureCredential();
  console.log(credential);
  const client = new WebSiteManagementClient(credential, subscriptionId);
  const result =
    await client.staticSites.beginCreateZipDeploymentForStaticSiteAndWait(
      resourceGroupName,
      name,
      staticSiteZipDeploymentEnvelope
    );
  console.log(result);
}

deployASiteFromAZippedPackage().catch(console.error);

Environment

No response

Event Grid Manager hangs creating event topic subscription

Library name and version

com.azure.resourcemanager:azure-resourcemanager-eventgrid:1.2.0-beta.3

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

I'm trying to create a subscription using the EventGridManager, if the webhook endpoint for the destination is good everything works, but if the endpoint is not a valid webhook, the service hangs indefinitely. Is there a way to set a timeout? so that the service doesn't hangs, as right now I need to interrupt the thread.

Thanks

EventSubscription eventSubscription = manager.topicEventSubscriptions()
  .define(eventSubscriptionName)
  .withExistingTopic(resourceGroupName, eventGridTopicName)
  .withDestination(destination)
  .create();

Expected behavior

If the endpoint is not valid a timeout a default timeout happens and fails, and this timeout can be set from the create method.

Actual behavior

On wrong endpoint the thread hangs indefinitely

Reproduction Steps

Try to create a subscription using "www.microsoft.com" as endpoint

var url = URI.create("www.microsoft.com");
WebhookEventSubscriptionDestination destination = new WebhookEventSubscriptionDestination()
  .withEndpointUrl(url.toString());

EventSubscription eventSubscription = manager.topicEventSubscriptions()
  .define(eventSubscriptionName)
  .withExistingTopic(resourceGroupName, eventGridTopicName)
  .withDestination(destination)
  .create();

Environment

Java: 17
Windows 11
Maven 3.8.7
Intellij Idea 2021.3.3

[Python] AttributeError: 'CognitiveServicesManagementClient' object has no attribute 'deployments'

Link to sample

https://learn.microsoft.com/en-us/rest/api/cognitiveservices/accountmanagement/deployments/list?view=rest-cognitiveservices-accountmanagement-2023-05-01&tabs=Python

Library name and version

azure-mgmt-cognitiveservices==13.5.0

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

This part of the code:

deployment = cognitiveservices_client.deployments.begin_create_or_update(
    resource_group_name = resource_group_name,
    account_name = account_name,
    deployment_name = "chat",
    deployment = {
        "properties": {"model": {"format": "OpenAI", "name": "ada", "version": "1"}},
        "sku": {"capacity": 1, "name": "Standard"},
    },
)

results in this error:

AttributeError: 'CognitiveServicesManagementClient' object has no attribute 'deployments'

Expected behavior

I expect this code to create a deployment in the Azure OpenAI account. Creating deployments manually in the Azure Portal by using Azure AI Studio works without any problems.

Actual behavior

Not creating any deployments within the OpenAI account.

Reproduction Steps

Create an account like this:

from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient

cognitiveservices_client = CognitiveServicesManagementClient(
    credential=credential,
    subscription_id=subscription_id
)

account_name = "anyname12345"

account = cognitiveservices_client.accounts.create(
    resource_group_name,
    account_name,
    {
      "location": "West Europe",
      "kind": "OpenAI",
      "sku": {
        "name": "S0"
      },
      "identity": {
        "type": "SystemAssigned"
      }
    }
)
print("Created OpenAI account:\n{}".format(account))

This should work and should output something like this:

Created OpenAI account:
{'additional_properties': {}, 'etag': '"200035e7-0000-0d00-0000-65a30a020000"', 'id': '/subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/Microsoft.CognitiveServices/accounts/<account_name>', 'kind': 'OpenAI', 'location': 'West Europe', 'name': '<account_name>', 'properties': <azure.mgmt.cognitiveservices.models._models_py3.CognitiveServicesAccountProperties object at 0x7fc63c41fc10>, 'sku': <azure.mgmt.cognitiveservices.models._models_py3.Sku object at 0x7fc63c41fdf0>, 'tags': None, 'type': 'Microsoft.CognitiveServices/accounts', 'identity': <azure.mgmt.cognitiveservices.models._models_py3.Identity object at 0x7fc63c41f2b0>}

Now try to get a list of deployments or create a deployment with that same cognitiveservices_client object:

    response = cognitiveservices_client.deployments.list(
        resource_group_name=resource_group_name,
        account_name=account_name
    )

or

deployment = cognitiveservices_client.deployments.begin_create_or_update(
    resource_group_name = resource_group_name,
    account_name = account_name,
    deployment_name = "chat",
    deployment = {
        "properties": {"model": {"format": "OpenAI", "name": "ada", "version": "1"}},
        "sku": {"capacity": 1, "name": "Standard"}
    }
)
print(deployment)

This should cause an error.

Environment

Authenticating as follows:

!az login --tenant $AZURE_TENANT --use-device-code --output none
from azure.identity import AzureCliCredential
credential = AzureCliCredential()

Using the following Python packages:
azure-mgmt-cognitiveservices==13.5.0

Python version: 3.8.18
JupyterLab version 3.4.4

Similar

  1. bug

Filter data based on usage_date

Link to sample

https://learn.microsoft.com/en-us/rest/api/cost-management/benefit-utilization-summaries/list-by-billing-account-id?tabs=Python

Library name and version

savingsplan utilization data

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

How can I filter savingsplan utilization based on usage_date in python. so that i can extract data for a month everytime.

Expected behavior

No response

Actual behavior

No response

Reproduction Steps

No response

Environment

No response

Unable to GET Role Definition by Role Name

Link to sample

https://learn.microsoft.com/en-us/rest/api/authorization/role-definitions

Library name and version

github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

Using the Azure CLI it is possible to obtain a role by its name like this: az role definition list --name MyRoleName
Using the API (or any SDK, since these use the API) I am only able to get roles by ID.
IDs are non-user-friendly Azure generated UUIDs.

Expected behavior

API documentation for Get states that it "Gets a role definition by name", while GetByID "Gets a role definition by ID".

Actual behavior

Both get the role by ID.

Reproduction Steps

GET https://management.azure.com/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}?api-version=2022-04-01

GET https://management.azure.com/roleDefinitionId?disambiguation_dummy&api-version=2022-04-01

Environment

Any

Keyvault latest version 1.1.0 does not support secrets.

Link to sample

No response

Library name and version

Azure.ResourceManager.Keyvault

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

We are migrating from Microsoft.Azure.Management.KeyVault SDK to the new Azure.ResourceManager.KeyVault SDK (latest 1.1.0)

  1. We noticed that the latest version did not contain Secret resource or any capability to support secrets. No example found for the same.
  2. We downgraded the version to 1.0.0.-beta8. Even though it supports SecretResource, we are unable to fetch any secrets in the code. The value remains null.

Please provide examples or guidance to fetch Secret resource.

Expected behavior

No response

Actual behavior

No response

Reproduction Steps

No response

Environment

development

listByRequest errors on returned payload

Link to sample

https://learn.microsoft.com/en-us/rest/api/apimanagement/reports/list-by-request?view=rest-apimanagement-2022-08-01&tabs=HTTP

Library name and version

@azure/arm-apimanagement 9.1.0

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

When trying the sample in typescript following error is thrown:
RestError: Error "SyntaxError: Unexpected token  in JSON at position 0" occurred while parsing the response body - {"value":

All the other report functions work like expected

Expected behavior

Like described in the sample
an array that looks like
{
"value": [
{

Actual behavior

RestError: Error "SyntaxError: Unexpected token  in JSON at position 0" occurred while parsing the response body - {"value":

Reproduction Steps

follow the sample

Environment

ES2022

[Sample Issue]

Link to sample

sdfa

Library name and version

22

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

aoa

Expected behavior

No response

Actual behavior

No response

Reproduction Steps

No response

Environment

No response

client.big_data_pools.update for "Update a Big Data pool" does not work

Link to sample

No response

Library name and version

from azure.mgmt.synapse import SynapseManagementClient

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

respone = client.big_data_pools.update(
    resource_group_name=azure_resource_group_name,  # "rg-res895793475",
    workspace_name=azure_workspace_name,            # "synrgres0013594875937",
    big_data_pool_name=azure_big_data_pool_name,    # "synspsmall8787",
    big_data_pool_patch_info={
        "properties": {
            "AutoScaleProperties": {
                "enabled": True,
                "maxNodeCount": 3,
                "minNodeCount" : 5
            }
        }
    }
)

Expected behavior

The auto-scale value should switch from false to true and the max parameter should be 5

Actual behavior

auto-scale is still false and max nodes is still 3

Reproduction Steps

No response

Environment

Python 3.10.8 and latest Azure Python Frameworks

from azure.identity import DefaultAzureCredential
from azure.mgmt.synapse import SynapseManagementClient

policyStates.summarizeForManagementGroup

Link to sample

No response

Library name and version

https://learn.microsoft.com/es-es/rest/api/policy/policy-states/summarize-for-management-group?tabs=JavaScript#code-try-0

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

When executing this piece of code, it throws:

  • "Cannot use 'in' operator to search for 'queryOptions' in myManagementGroup"

Expected behavior

Return this:

{
  "@odata.context": "https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary",
  "@odata.count": 1,
  "value": [
    {
      "@odata.id": null,
      "@odata.context": "https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyStates/$metadata#summary/$entity",
      "results": {
        "queryResultsUri": "https://management.azure.com/providers/Microsoft.Management/managementGroups/myManagementGroup/providers/Microsoft.PolicyInsights/policyStates/latest/queryResults?api-version=2019-10-01&$from=2019-10-05 18:00:00Z&$to=2019-10-06 18:00:00Z&$filter=(PolicyDefinitionAction eq 'deny' or PolicyDefinitionAction eq 'audit') and IsCompliant eq false",
        "nonCompliantResources": 15410,
        "nonCompliantPolicies": 68,
        "resourceDetails": [
          {
            "complianceState": "compliant",
            "count": 1400
          },
          {
            "complianceState": "noncompliant",
            "count": 15410
          }
        ],
        "policyDetails": [
          {
            "complianceState": "noncompliant",
            "count": 68
          }
        ],
        "policyGroupDetails": [
          {
            "complianceState": "noncompliant",
            "count": 14
          }
        ]
      },
      "policyAssignments": []
    }
  ]
}

Actual behavior

Using my own management group name, with and without options, same result.

  "trace": [
    "TypeError: Cannot use 'in' operator to search for 'queryOptions' in stz",
    "    at getPropertyFromParameterPath (/opt/nodejs/node_modules/@azure/core-client/dist/index.js:1144:41)",
    "    at getOperationArgumentValueFromParameter (/opt/nodejs/node_modules/@azure/core-client/dist/index.js:1103:44)",
    "    at calculateQueryParameters (/opt/nodejs/node_modules/@azure/core-client/dist/index.js:1719:39)",
    "    at getRequestUrl (/opt/nodejs/node_modules/@azure/core-client/dist/index.js:1647:45)",
    "    at PolicyInsightsClient.sendOperationRequest (/opt/nodejs/node_modules/@azure/core-client/dist/index.js:1902:21)",
    "    at PolicyStatesImpl.summarizeForManagementGroup (/opt/nodejs/node_modules/@azure/arm-policyinsights/dist/index.js:6411:28)",
    "    at Runtime.exports.handler (/var/task/index.js:27:44)",
    "    at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1147:29)"
  ]

Reproduction Steps

Try to run the provided code sample.

Environment

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.