microsoft / azure-api-management-monetization

MIT License
54 stars 30 forks source link

When running Stripe Initialization Script, it says "Resource group not found" #29

Closed Rob97 closed 2 years ago

Rob97 commented 2 years ago

I know it is because the resource group is under a specific subscription. I tried switching to that by saying "Select-AzSubscription -SubscriptionName '' but I still get the same error.

Here is the error:

Error: (ResourceGroupNotFound) Resource group '[REDACTED RESOURCE GROUP NAME]' could not be found. Code: ResourceGroupNotFound Message: Resource group '[REDACTED RESOURCE GROUP NAME]' could not be found.

Could we instead have the subscription key also be added as a parameter for the script? This would make sure the resource group can be found. Just an idea, but would love any help.

Smartitect commented 2 years ago

Can you confirm you are getting this error when you run the stripeInitialisation.ps1 script?

The script is using the Azure CLI, not the Azure PowerShell module which is why your attempt to set the subscription using Select-AzSubscription -SubscriptionName didn't work.

Could you try running the following commands:

Log in using the Azure CLI: az login

Set the default subscription to the ID of the subscription which contains the resource group: az account set --subscription [SUBSCRIPTION_ID]

Then run the stripeInitialisation.ps1 script.

Let us know if that works. Your suggestion to add the subscription ID as a script parameter is a good one - we can look into implementing that.

Rob97 commented 2 years ago

Yes, I am running the stripeInitialisation.ps1 script.

Thank you, hopefully, the subscription ID parameter will streamline the process even more.

If I try the Azure CLI on my local computer I get the following error:

./payment/stripeInitialisation.ps1 ./payment/stripeInitialisation.ps1 : File {REDACTED}\azure-api-management-monetization\payment\stripeInitialisation.ps1 cannot be loaded. The file {REDACTED}\azure-api-management-monetization\payment\stripeInitialisation.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1

I then tried to set the execution policy but that still didn't work. I used "Set-ExecutionPolicy -ExecutionPolicy AllSigned" but as I pointed out below, " Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass" worked to fix the above error.

But regardless, I have to use the PowerShell on Azure itself as it is not working locally. After making your suggested change above, the code was able to find the resource group. Thank you for the suggestion! However, it, unfortunately, is still showing an error and I am not sure what to do. I uploaded the stripeInitialization.ps1 script to Azure and it is giving the following error after attempting to run the script. I am quite confused as to what to do next.

New Error: stripeInitialisation.ps1: The term 'stripe /home/tools/stripe/1.5.13/stripe' is not recognized as a name of a cmdlet, function, script file, or executable program.

Rob97 commented 2 years ago

So I have tried over and over again to run it locally but to no avail. I had to first run " Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass" on Admin to even get the permission to run the script on my local powershell.

It shows that the OS is unsupported but I am using Windows 11.

Error: Unsupported OS At {REDACTED}\azure-api-management-monetization\payment\stripeInitialisation.ps1:42 char:5 throw "Unsupported OS"


 CategoryInfo : OperationStopped: (Unsupported OS:String) [], RuntimeException
 FullyQualifiedErrorId : Unsupported OS
Smartitect commented 2 years ago

Hello - glad to hear you have managed to address the resource group issue.

On the new issue above, please can you check which version of PowerShell you have installed on your machine? The pre-requisite for this project is PowerShell 7.1 - from the error message above, it appears that you may be using an older version.

Please refer to the documentation for details.

Rob97 commented 2 years ago

Hello, so I was using the Azure portal's PowerShell and it actually ended up working after I accidentally added "\" at the end of the resource groups name when inputting the parameters. Not sure why but glad I was finally able to get through this issue. Thank you for your assistance!