Add existing resources#2642
Conversation
44cfd4c to
ca2baf7
Compare
40ae2c6 to
c4b43c6
Compare
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
* Adds the NATS 9.1 API and fixes obsolete API. Closes dotnet#1817 * Fix link
| > [!NOTE] | ||
| > Not all APIs are available on all Azure resources. For example, some Azure resources can be containerized or emulated, while others cannot. | ||
|
|
||
| When it comes to specifying whether an Azure resource in the app model is an existing resource, you can use the `AsExisting` API. The `AsExisting` method marks the resource as an existing resource in both run and publish modes. You can query whether a resource has been marked as an existing resource, by calling the `IsExisting` extension method on the <xref:Aspire.Hosting.ApplicationModel.IResource>. For more information, see [Mark Azure resources as existing](#mark-azure-resources-as-existing). |
There was a problem hiding this comment.
I feel like AsExisting should be in the table above. Was there a reason why it isn't?
There was a problem hiding this comment.
I felt like it didn't belong since it does both modes, I suppose there could be a column with the applicable mode, or something?
There was a problem hiding this comment.
Table would be fine. We'd also want somewhere to capture the info I shared in #2642 (comment). A table might get a little too stuffy if we added all that?
There was a problem hiding this comment.
I think the info in #2642 (comment) belongs in a paragraph form here.
Having AsExisting in the table calls attention to it and puts it on the same level as RunAsExisting and PublishAsExisting. I think it belongs in the same spot(s).
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
|
|
||
| The consuming API project uses the connection string information with no knowledge of how the app host configured it. In "publish" mode, the code adds a new Azure Storage resource—which would be reflected in the [deployment manifest](../deployment/manifest-format.md) accordingly. When in "run" mode, the connection string corresponds to a configuration value visible to the app host. It's assumed that any and all role assignments for the target resource have been configured. This means, you'd likely configure an environment variable or a user secret to store the connection string. The configuration is resolved from the `ConnectionStrings__storage` (or `ConnectionStrings:storage`) configuration key. These configuration values can be viewed when the app runs. For more information, see [Resource details](../fundamentals/dashboard/explore.md#resource-details). | ||
|
|
||
| ## Mark Azure resources as existing |
There was a problem hiding this comment.
@captainsafia - what is your thoughts on moving this above Add existing Azure resources with connection strings?
There was a problem hiding this comment.
I like that with this format we have a segue from the connection strings approach to the bicep one. Although it does make it seem like connection strings are preferred to bicep. We can consider re-arranging it and maybe making the connection string stuff an H3 under existing resources instead of an H2?
There was a problem hiding this comment.
We can consider re-arranging it and maybe making the connection string stuff an H3 under existing resources instead of an H2?
I like this idea.
Although it does make it seem like connection strings are preferred to bicep.
Yes, that was my thinking. I think we should suggest using the new "Existing" feature first, because it works so much better and enables so many more scenarios.
There was a problem hiding this comment.
How about we restructure/flow of the article to be the following (only looking at H2s and only highlighting changes to H3):
- Naming conventions and APIs for expressing Azure resources
- Add Azure resources
- Mark Azure resources as existing
- Add existing Azure resources with connection strings
- Infrastructure as code
- Publishing
Perhaps both the existing APIs bits and the connection string blurbs should be H3s, under the Add Azure resources heading? Thoughts? Admittedly, there are other H3s and H4s that were omitted from here.
There was a problem hiding this comment.
I like moving the "as existing" and "connection string" stuff lower than the "typical devloper experience" stuff. We should have the normal cases first - when you add a new resource, not use an existing one. I also like having "as existing" above "connection string". So I think this proposal sounds good to me.
| The NATS JetStream functionality provides a built-in persistence engine called JetStream which enables messages to be stored and replayed at a later time. You can optionally provide a `srcMountPath` parameter to specify the path to the JetStream data directory on the host machine (the provided mount path maps to the container's `-sd` argument). | ||
| The NATS JetStream functionality provides a built-in persistence engine called JetStream which enables messages to be stored and replayed at a later time. | ||
|
|
||
| ### Add NETS server resource with authentication parameters |
There was a problem hiding this comment.
| ### Add NETS server resource with authentication parameters | |
| ### Add NATS server resource with authentication parameters |
There was a problem hiding this comment.
These commits mistakenly came over from a rebase, I'll incorporate the feedback elsewhere. Thank you.
| ```csharp | ||
| var builder = DistributedApplication.CreateBuilder(args); | ||
|
|
||
| var username = builder.AddParameter("username", secret: true); |
There was a problem hiding this comment.
| var username = builder.AddParameter("username", secret: true); | |
| var username = builder.AddParameter("username"); |
Typically we don't mark usernames as secret...?
There was a problem hiding this comment.
These commits mistakenly came over from a rebase, I'll incorporate the feedback elsewhere. Thank you.
| ```csharp | ||
| var builder = DistributedApplication.CreateBuilder(); | ||
|
|
||
| var existingResourceName = builder.AddParameter("existingResourceName"); |
There was a problem hiding this comment.
| var existingResourceName = builder.AddParameter("existingResourceName"); | |
| var existingResourceName = builder.AddParameter("existingServiceBusName"); |
?
| - Adds an Azure Service Bus resource named `messaging` to the builder. | ||
| - Calls the `RunAsExisting` method on the `serviceBus` resource builder, passing the `existingResourceName` parameter—alternatively, you can use the `string` parameter overload. | ||
| - Adds a queue named `queue` to the `serviceBus` resource. | ||
|
|
There was a problem hiding this comment.
We should add that the ServiceBus is assumed to be in the same Resource Group as your app is using.
| var serviceBus = builder.AddAzureServiceBus("messaging") | ||
| .PublishAsExisting(existingResourceName) | ||
| .WithQueue("queue"); |
There was a problem hiding this comment.
| var serviceBus = builder.AddAzureServiceBus("messaging") | |
| .PublishAsExisting(existingResourceName) | |
| .WithQueue("queue"); | |
| var serviceBus = builder.AddAzureServiceBus("messaging") | |
| .PublishAsExisting(existingResourceName); |
WithQueue was removed in 9.1
There was a problem hiding this comment.
If you want to convert it, use:
var serviceBus = builder.AddAzureServiceBus("messaging")
.PublishAsExisting(existingResourceName);
serviceBus.AddServiceBusQueue("queue");
AddServiceBusQueue returns the queue resource. (Just like AddDatabase returns the child database resource)
There was a problem hiding this comment.
Good catch, thanks for helping out with this.
Co-authored-by: Safia Abdalla <safia@safia.rocks>
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
|
We need to explain exactly how RunAsExisting and PublishAsExisting works (this is key to helping people understand and troubleshoot when things go wrong). PublishAsExisting without a resource group is kinda pointless by default since we are creating a new resource group the first time you deploy. We should mention this somewhere… |
Does it make sense that resource group is an optional parameter then? It doesn't seem optional. cc @captainsafia |
It should be possible to publish to an existing RG, right? https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/resource-group-scoped-deployments But that case might be less common, so maybe it is better to require the dev to explicitly say |
I don't think we necessarily need to change the existing signatures in 9.1 to react to this. If we do, I'd prefer that we change to making the resource group a required parameter on the That being said, I think the immediate problem that @davidfowl is more about how explicit we want to be about what happens under the hood in the docs. Right now, we show the generated aspire-manifest and bicep definitions when you publish but don't necessarily explain what those deltas mean in the bigger context of the deployment. |
|
Closed by #2653 |
Summary
New content detailing the
AsExisting,RunAsExisting, andPublishAsExistingAPIs.Fixes #2549
Internal previews