Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

There is no way to create a Subscription using this SDK. #23885

Open
saqib-ali-cof opened this issue Dec 20, 2024 · 5 comments
Open

There is no way to create a Subscription using this SDK. #23885

saqib-ali-cof opened this issue Dec 20, 2024 · 5 comments
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@saqib-ali-cof
Copy link

There appears to be no way to create a subscription using the Azure SDK for GoLang.

Here is sample code I found to do something similar:

clientFactory, err := armapimanagement.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
    log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewSubscriptionClient().CreateOrUpdate(ctx, "rg1", "apimService1", "testsub", armapimanagement.SubscriptionCreateParameters{
    Properties: &armapimanagement.SubscriptionCreateParameterProperties{
        DisplayName: to.Ptr("testsub"),
        OwnerID:     to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57127d485157a511ace86ae7"),
        Scope:       to.Ptr("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060002"),
    },
}, &armapimanagement.SubscriptionClientCreateOrUpdateOptions{Notify: nil,
    IfMatch: nil,
    AppType: nil,
})

However, this doesn't seem to work if the subscription doesn't already exist.

Since I want to create a brand new Subscription, what do I pass in for the first 3 arguments to CreateOrUpdate()?
It needs a resourceGroupName, a serviceName and an SID.

Those three values are used by CreateOrUpdate() to construct the following URL: urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}"

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Dec 20, 2024
@tadelesh tadelesh added Mgmt This issue is related to a management-plane library. and removed needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Dec 23, 2024
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Dec 23, 2024
@jliusan
Copy link
Member

jliusan commented Dec 24, 2024

@saqib-ali-cof could you turn on logging by setting environment variable AZURE_SDK_GO_LOGGING to all and configure policy.LogOption to print the body of this call? Please help to check the details info in the raw response.

https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/new-version-guideline.md#logging

@saqib-ali-cof
Copy link
Author

@jliusan Perhaps I misunderstand you.

I can turn on logging, but what exactly do you want me to run?
I don't have code that will create an Azure Subscription, so turning on logging to find out more details about this non-existent code won't work

@tadelesh
Copy link
Member

first, you need to have an api management service. then you could use this api to create new subscription. the first two parameter is the resource group and service name of your api management service, the third parameter is just a name for the new subscription you want to create.

@saqib-ali-cof
Copy link
Author

@tadelesh thank you. But why do I need a Resource Group to create a subscription? Whats the relationship between the two? What if I don't have a resource group? Then I cannot create a subscription??

@tadelesh
Copy link
Member

the resource group is where you create the api management service. it is only used to locate the api management service you use to create subscription. it is not related with the subscription you want to create.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

3 participants