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

Refactor samples with terraform and defaultCredential for Eventhubs samples #136

Conversation

backwind1233
Copy link
Contributor

@backwind1233 backwind1233 commented Jan 4, 2022

As title

linked issue: Azure/azure-sdk-for-java#25652
parent-pr:#133

@backwind1233 backwind1233 self-assigned this Jan 4, 2022
@backwind1233 backwind1233 added the azure-spring All azure-spring related issues label Jan 4, 2022
After login Azure CLI with your account, now you can use the terraform script to create Azure Resources.

```shell
# In the root directory of the sample
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the terraform packages be installed to the current folder each time I run the sample

Initializing the backend...

Initializing provider plugins...
- Finding aztfmod/azurecaf versions matching "1.2.10"...
- Finding hashicorp/azurerm versions matching ">= 2.75.0"...
- Installing aztfmod/azurecaf v1.2.10...
- Installed aztfmod/azurecaf v1.2.10 (signed by a HashiCorp partner, key ID 580D6CA803522E7E)
- Installing hashicorp/azurerm v2.90.0...
- Installed hashicorp/azurerm v2.90.0 (signed by HashiCorp)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the log running terraform -chdir=./terraform init
I didn't paste the log in the readme.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean the package will be installed under each sample,
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the terraform packages be installed to the current folder each time I run the sample

Initializing the backend...

Initializing provider plugins...
- Finding aztfmod/azurecaf versions matching "1.2.10"...
- Finding hashicorp/azurerm versions matching ">= 2.75.0"...
- Installing aztfmod/azurecaf v1.2.10...
- Installed aztfmod/azurecaf v1.2.10 (signed by a HashiCorp partner, key ID 580D6CA803522E7E)
- Installing hashicorp/azurerm v2.90.0...
- Installed hashicorp/azurerm v2.90.0 (signed by HashiCorp)

yes, you are right

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we improve this, or is it possible to share these packages in the whole repo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use TF_DATA_DIR as the only folder for the downloaded providers, but it seems not to work as expected, each sample will download again, even the provider has been downloaded in the folder.


5. Delete the resources on [Azure Portal][azure-portal] to avoid unexpected charges.

### Use Azure Resource Manager to retrieve connection string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have another configuration file to demonstrate this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, I will track it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracked in this issue: Azure/azure-sdk-for-java#26407

```shell
terraform -chdir=./terraform destroy
```


## Enhancement
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the Enhancement here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in the original doc, not sure, let me ask @yiliuTo for help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked with Yi with Teams, I think we can keep this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@backwind1233 @yiliuTo do you think we should have an extended step for all of our samples, and link them to the reference doc perhaps, maybe we should put this enhancement section into the reference doc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both for me are ok, how do you think about it @yiliuTo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that ref docs should have enhancement introduction, and as for the samples, referring to other open source sample projects, like scs, gcp,, they split each sample project in the way that each sample only introduces one feature, and then the readme could have a short introduction about that feature. Perhaps we could consider this option in the future.
And for now, I agree with @saragluna 's suggestion to put the enhancement in ref docs and a link of it in the samples.

Copy link
Contributor Author

@backwind1233 backwind1233 Jan 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I will add an issue to track this, but deleted it in the readme files at this moment.
After the Enhancement part is added in the reference docs, I will paste the link in the sample readme files.

@@ -1,331 +1,164 @@
# Spring Cloud Azure Stream Binder for Multiple Event Hubs Namespace Code Sample shared library for Java
# Spring Cloud Azure Stream Binder for Multiple Event Hubs Namespace Code Sample shared library for Java
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tile should be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@@ -1,210 +1,164 @@
# Spring Cloud Azure Stream Binder for Event Hub Code Sample shared library for Java
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title of this article should be updated too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


## Key concepts
This sample demonstrates how to use the `Spring Cloud Stream Binder`
for multiple `Azure Event Hubs` namespaces. In this sample you will bind to
two Event Hubs namespaces separately through two binders. The sample app has two operating modes.
One way is to expose a Restful API to receive string message, another way is to automatically provide string messages.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RESTful

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

# Apply your Terraform Configuration
# Type `yes` at the confirmation prompt to proceed.
terraform -chdir=./terraform apply
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run into this error when running terraform

Error: creating Azure Storage Account "steventhubsmultibinders": storage.AccountsClient#Create: Failure sending request: StatusCode=0 -- Original Error: autorest/azure: Service returned an error. Status=<nil> Code="StorageAccountAlreadyExists" Message="The storage account named steventhubsmultibinders already exists under the subscription."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because the storage account name has a 24 char length limit, and the application name takes 22 chars (removing the '-'), leaves 2 chars for the random chars. Maybe we can change the name = var.application_name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same error happened for the spring integration eventhubs sample.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated for azurerm_storage_account

}

resource "azurerm_storage_container" "storage_container" {
name = "eventhubs-integration-sample"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the storage container name is not matching.

@backwind1233 backwind1233 merged commit 9f96983 into Azure-Samples:spring-cloud-azure_4.0 Jan 13, 2022
@backwind1233 backwind1233 deleted the 1228_defaulttokencredential_gzh_eventhubs branch January 13, 2022 05:41
stliu added a commit that referenced this pull request Mar 29, 2022
* migrate to Spring Cloud Azure 4.0 (#73)

* add pom

* update storage sample to use spring cloud azure 4.0

* update condition with matching bean instead of properties

* remove version since we have added this dependency to bom

* Update the servicebus binder samples.

* Change folder name from "azure-spring-boot-starter-keyvault-secrets" to "spring-cloud-azure-starter-keyvault-secrets".

* Change parent's artifactId to azure-spring-boot-samples.

* Change sample's artifactId.

* Delete dependencyManagement.

* Change dependency to spring-cloud-azure-starter-keyvault-secrets.

* Change configuration property prefix from `azure.keyvault.` to `spring.cloud.azure.keyvault.secret.`.

* add si sample

* modify sb binder

* add new sample

* Update servicebus binder samples.

* update sample

* rename directory

* remove unnecessary dependencies

* update for multiple ns

* Update pom and readme of servicebus binder samples.

* delete samples

* update configuration for sp/msi credential

* remove javadoc

* Update application-mi.yaml,application-sp.yaml,application.yaml and readme of servicebus binder samples.

* Update Cache and Kafka sample

* servicebus-jms sample update for 4.0

* Update the catalog and readme of servicebus binder samples.

* Delete old link.

* Delete unused contents.

* Update application.yml.

* Delete unused code.

* Add new configuration item: property-source-enabled.

* update binder directory

* Fix error in application.yml.

* Update README.md.

* Change the placeholder in application.yml.

* Update configuration and link.

* update the kafka sample to make it not required to depend on eh sdk or resource manager

* Update configuration and link.

* Update  cosmos storage samples follow convention with spring cloud azure 4.0 (#88)

* servicebus-jms sample update for 4.0(artifact-id,link)

* fix sb-si sample

* Change folder's name to "single-property-source".

* Change sample's artifact name.

* Change package name.

* Change placeholder to upper case.

* Fix parent.relativePath.

* Add new sample: Key Vault secrets, multiple property source.

* Update the property name.

* Change the application class name.

* Update README.md.

* merge 4.0 branch (2.0)

* update README.md

* update directory name

* Use version 4.0 for aad related sample (#72)

* remove auto create resources in sb-si samples

* Remove unused samples and add relativePath (#92)

* Update the readme and properties configuration of servicebus multibinders.

* Change the representation of value.

* Change the version comment of pom.

* update version.spring.cloud.azure to 4.0.0-beta.2

* 1. update readme links to 4.0.0-beta.2
2. delete cloudfoundry

* Change the representation of value in yaml and readme.

* Revert "1. update readme links to 4.0.0-beta.2"

This reverts commit 6ed8967.

* update readme links to 4.0.0-beta.2

* add cloudfoundry entry

* remove conditionalbean on storage

* Delete the build in the pom and modify the value representation.

* add entry for keyvault jca

* Update all AAD sample's application.yml.

* Change to upper case for all placeholders.

* Delete readme headers (#91)

* Add dependencyManagement to use version 4.0.0-beta.3.

* Fix warning: redundant definition of groupId.

* update samples for eventhubs related project (#103)

* update samples for eventhubs related project

* fix some typo errors and formats

* fix some typo errors and formats

* fix some typo errors and formats

remove header info

* fix some typo errors and formats

rearrange Enhencement Section

* Update properties in README.md.

* Fix compile error.

* Update indent: Use space instead of tab.

* Copy files from this repo: https://github.com/Azure-Samples/spring-boot-application-with-azure-active-directory

* Delete unused files.

* Add "aad/spring-security" into root pom.

* Delete "multi version support" related content in README.md.

* Point out that these samples are using spring-security.

* Delete all links related to this repo: https://github.com/Azure-Samples/spring-boot-application-with-azure-active-directory

* Make AAD B2C support global properties.

* Add dependencyManagement to use latest version.

* Update package names after api-review.

* Delete unused files.

* Update .gitignore:
1. Ignore property file used for local test.
2. Remove duplicated item.

* add description for content type of batch mode

* Delete number in folder name and artifact id.

* Update module name in pom.

* Add a new sample: OAuth2 Login.

* Add document about login sample.

* Run sample with terraform and Default Azure Credential (#104)

* run sample with terraform and tokencredential

* add random value to create resourcegroup and servicebus

* add servicebus namespace output

* update servicebus_namespace name

* update readme and tf script

* add "Azure Service Bus Data Owner" for current user.

* update readme for single-namespace

* - init config with terraform for demo multi-namespace

* update application configuration

* init README.md

* add git ignore file for terraform

* format git ignore file

* update readme

* update readme

* clean up script

* bugfix: create servicebus group

* update README.md

* remove application-mi,sp.yaml

* export values to environment_values.sh

* update readme

* make sure environment_values.sh is clean

* fix README.md errors

* add null_resource

* add **/terraform/environment_values.sh to gitignore

* add **/terraform/.terraform.lock.hcl to gitignore

* format README.md

* Revert "format README.md"

This reverts commit 7ee7b77.

* remove unused variables

* fix the error when running shell scipt

* fix typo

* add .history/ to gitignore

* fix sample configuration bug

* fix env issue

* remove unused output

* update terrafrom and README.md

* add resources tags

* use var

* remove unused terraform provider

* fix typo

Co-authored-by: Strong Liu(刘少壮) <shaozliu@microsoft.com>

* Fix link error in keyvault-jca sample README.md

* Fix error about redirect uri template.

* modify autoconfiguration error (#123)

* Refactor with terrafrom and defaultCredential for keyvault sample (#126)

* Refactor with terrafrom and defaultCredential for storage and cosmos (#125)

* Add description for role assignment in Spring Cloud Azure samples. (#127)

* format tf scripts (#135)

* Fix the error in the appconfiguration samples (#121)

* Update the parent pom of the spring-security module in aad.

* Change version to 1.0.0 for spring security related samples (#145)

* Update the name of sample modules (#128)

* Updated Feature Management Readme

* Update petclinic with latest spring integration libraries (#131)

* Update spring.cloud.azure version from 4.0.0-beta.2 to 4.0.0-beta.3 (#146)

* Update permissons for servicebus namespaces (#148)

* Update README.md (#140)

* Refactor samples with terraform and defaultCredential for keyvault samples (#137)

* Fix break changes servicebus in 4.0.0-beta.3 (#150)

* 1. Update the property name. (#151)

2. Fix error in README.md.

* Create sample spring-cloud-gateway + AAD resource server (#147)

* Fix problems in pom files (#154)

* Add "<packaging>jar</packaging>".

* 1. Update the order according to pom code convention: https://maven.apache.org/developers/conventions/code.html#pom-code-convention
2. Delete parentId because it's same to parent's parentId.
3. Uniform the indent in one file.

* 1. Delete duplicated dependency.

* Refactor samples with terraform and defaultCredential for Eventhubs samples (#136)

* Refactor samples with terraform and defaultCredential for Storage Queue samples (#139)

* Refactor  Service Bus sample:multiple-namespaces and eventhubs-integration (#134)

* Refactor samples with terraform and defaultCredential for Servicebus samples (#138)

* Fix Storage Queue compilation error

* Remove unused files (#156)

* Fix issues caused by line breaks (#155)

* Update readme and terraform scripts (#159)

* Update broken links (#161)

* Update storage queue beta4 (#164)

* update to 4.0.0-beta.4 (#166)

* Update redis kafka sample (#165)

* Update Storageblob sample (#171)

* fix terraform outputs.tf error (#173)

* - clean unused imports (#174)

* Support terraform to run in Powershell. (#168)

* Add resource manager usage for sample readme (#169)

* Add some information in root readme (#176)

* Remove unnecessary dependencyManagement config and update webclient config. (#179)

* Remove test folders and dependencies for beta.4 branch (#184)

* Update versions and dependencymanagement (#180)

* Remove test folders in petclinic samples (#189)

* Refactor sample_cosmos.azure-spring-data-cosmos (#187)

* Refactor sample_spring-petclinic-microservices. (#186)

* Update github actions (#191)

Co-authored-by: backwind <zhihaoguo@foxmail.com>

* Update pom.xml

* Change order of properties in pom.xml (#197)

* Update README.md

* Update pom.xml

* Add resouce group in output gzh (#201)

* update springboot version (#200)

* Update markdown-link-check.yml

* Fix compilation error to update latest code on 4.0 branch (#203)

* fix compilation error after 4.0 branch changes

* fix compilation error after 4.0 branch changes (#204)

* simple improvement (#205)

* avoid hard code resource (#206)

* simplify code (#207)

* add link to reference doc (#199)

* add link to reference doc

* Sync the root package name change of Spring modules (#210)

* fix compilation error (#213)

* Rename from allowed-groups to allowed-group-names (#216)

* Fix readme doc issues of jca (#215)

* Fix error in setup_env.ps1 (#211)

* Feature/create sample about login authenticate using private key jwt (#196)

* Fix messaging sample (#219)

* change to eventhubs

* change to servicebus

* Keep the version of provider in terraform scripts fixed. (#218)

* Add section in readme for debugging samples (#212)

* add section to README.md to debug example.

* Add a new sample: key-vault-secret-client. (#220)

1. This sample is copied from "single-property-source".
2. Change package to "com.azure.spring.keyvault.secrets.sample.client".
3. In SampleApplication, Use SecretClient to get the secret value.
4. Delete unnecessary dependencies: spring-boot-starter-actuator and spring-boot-starter-web.
5. Update root pom and root README.md
6. Update the value stored in Azure Key Vault Secret, to make the output more clear.

* Use one sample to demonstrate the feature of keyvault secret property source (#221)

* fix checkpoint (#226)

* Add sample:servicebus-queue-binder-arm (#225)

* add sample

* Create README.md

* AAD support for terraform (#217)

* fix some errors (#227)

* fix some format for all the project. (#230)

* Update aad samples (#223)

* Update aad sample due to conditional access removal
* Make the aad reference classes not in implementation package

* change Lists from cosmos.impl package to guava Lists (#231)

* Update mlc_config.json

* Refactor multi-namespace sample of spring integration service bus (#233)

* remain compatible
* refactor sample

Co-authored-by: Xiaolu Dai <31124698+saragluna@users.noreply.github.com>

* Fix problem: pfx file not committed. (#232)

Co-authored-by: Xiaolu Dai <31124698+saragluna@users.noreply.github.com>

* Update keyvault property configuration. (#235)

Update the keyvault property configuration to make sure the sample works properly.

* Migration guide (#236)

* fix output scirpts (#237)

* Update petclinic sample & version upgrade (#229)

* Use terraform commands instead of az commands in shell script and upgrade version

Co-authored-by: Xiaolu Dai <31124698+saragluna@users.noreply.github.com>

* remove the spring data cosmos from the dependency management, the spring-cloud-azure-dependencies contains it (#238)

* Update version (#244)

* Complete keyvault sample (#245)

* add description

* change dir

* add more description

* Replace duplicate part. (#246)

* Update AAD Sample (#248)

* change aad-resource-server-by-filter
* change aad-resource-server-by-filter
* change aad-resource-server-by-filter-stateless

Co-authored-by: Xiaolu Dai <31124698+saragluna@users.noreply.github.com>

* upgrade spring cloud azure versions

* add missing project to aggregator

* change links and versions to 4.0.0

Co-authored-by: Strong Liu(刘少壮) <shaozliu@microsoft.com>
Co-authored-by: yonghuiye <hui1110rui@163.com>
Co-authored-by: Rujun Chen <rujche@microsoft.com>
Co-authored-by: yiliu6 <yiliu6@microsoft.com>
Co-authored-by: Moary Chen <v-moaryc@microsoft.com>
Co-authored-by: Muyao Feng <v-muyaofeng@microsoft.com>
Co-authored-by: zhihaoguo <zhihaoguo@microsoft.com>
Co-authored-by: Gary Liu <jialicrazy@163.com>
Co-authored-by: Yonghui Ye <58474919+hui1110@users.noreply.github.com>
Co-authored-by: mrm9084 <mrm9084@gmail.com>
Co-authored-by: Moary Chen <moary@126.com>
Co-authored-by: backwind <zhihaoguo@foxmail.com>
Co-authored-by: Muyao Feng <92105726+Netyyyy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure-spring All azure-spring related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants