Skip to content

Add location and subscription parameters to env new commad#164

Merged
karolz-ms merged 6 commits into
Azure:mainfrom
karolz-ms:karolz-ms/env-new-parameters
Jul 26, 2022
Merged

Add location and subscription parameters to env new commad#164
karolz-ms merged 6 commits into
Azure:mainfrom
karolz-ms:karolz-ms/env-new-parameters

Conversation

@karolz-ms
Copy link
Copy Markdown
Contributor

This change supports AZD integration with Visual Studio

Comment thread cli/azd/cmd/util.go Outdated
Copy link
Copy Markdown
Member

@ellismg ellismg left a comment

Choose a reason for hiding this comment

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

Some small changes requested - if there's a compelling reason for us to include priniciaplId right now I won't push back more - but this is an area where I've been feeling we don't have a great design and so if we can elevate the concept less right now, that would be ideal.

Comment thread cli/azd/cmd/util.go Outdated
Comment thread cli/azd/cmd/util.go Outdated
Comment thread cli/azd/cmd/env.go Outdated
@karolz-ms karolz-ms changed the title Add location, subscription, and principalID parameters to env new commad Add location and subscription parameters to env new commad Jul 25, 2022
@azure-sdk
Copy link
Copy Markdown
Collaborator

Azure Dev CLI Install Instructions

Install scripts

MacOS/Linux

May elevate using sudo on some platforms and configurations

curl -fsSL https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/164/uninstall-azd.sh | bash;
curl -fsSL https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/164/install-azd.sh | bash -s -- --base-url https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/164 --version '' --verbose

Windows

powershell -c "Set-ExecutionPolicy Bypass Process; irm 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/164/uninstall-azd.ps1' > uninstall-azd.ps1; ./uninstall-azd.ps1;"
powershell -c "Set-ExecutionPolicy Bypass Process; irm 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/164/install-azd.ps1' > install-azd.ps1; ./install-azd.ps1 -BaseUrl 'https://azuresdkreleasepreview.blob.core.windows.net/azd/standalone/pr/164' -Version '' -Verbose;"

Standalone Binary

Container

docker run -it azdevcliextacr.azurecr.io/azure-dev:pr-164

@jongio jongio added this to the Next milestone Jul 26, 2022
Copy link
Copy Markdown
Member

@ellismg ellismg left a comment

Choose a reason for hiding this comment

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

LGTM

@karolz-ms karolz-ms merged commit 929689a into Azure:main Jul 26, 2022
@karolz-ms karolz-ms deleted the karolz-ms/env-new-parameters branch July 26, 2022 18:09
v1212 pushed a commit to v1212/azure-dev that referenced this pull request May 12, 2026
…aults

- Fix gosec G304 warnings with nolint annotations for safe file reads
- Fix gosec G104 by properly handling tmpFile.Close() errors
- Fix gofmt formatting in excludeDirs map
- Update runtime choices to python_3_12/3_11/3_13 per spec
- Change --no-prompt deploy mode default to container (backward compat)
- Change --no-prompt runtime default to python_3_12
- Align prompt labels with spec wording
- Add container.resources + startupCommand to azure.yaml for code deploy
trangevi pushed a commit that referenced this pull request May 13, 2026
* feat(agents): add code deploy (ZIP upload) support for hosted agents

Implements code-based deployment as a complementary mode to container deploy.
Agents with code_configuration in agent.yaml are deployed via multipart
ZIP upload instead of Docker/ACR, eliminating permission complexity.

* feat(agents): add code deploy mode to 'azd ai agent init --from-code'

Add deploy mode prompt (code vs container) to the init flow. When code deploy is selected, prompts for runtime, entry_point, and dependency_resolution, then generates agent.yaml with code_configuration and azure.yaml with language: python (no Docker).

* fix(agents): address CI lint errors and align with spec #164 defaults

- Fix gosec G304 warnings with nolint annotations for safe file reads
- Fix gosec G104 by properly handling tmpFile.Close() errors
- Fix gofmt formatting in excludeDirs map
- Update runtime choices to python_3_12/3_11/3_13 per spec
- Change --no-prompt deploy mode default to container (backward compat)
- Change --no-prompt runtime default to python_3_12
- Align prompt labels with spec wording
- Add container.resources + startupCommand to azure.yaml for code deploy

* fix(agents): address Copilot review feedback on code deploy

- Add .azure and .env/.env.* to ZIP exclusion list to prevent uploading secrets
- Skip symlinks in WalkDir to avoid including files outside agent directory
- Stream ZIP directly to temp file with io.MultiWriter for SHA-256, reducing memory usage
- Clean up temp file on all error paths using deferred cleanup
- Only fall back to create agent on 404; propagate auth/5xx/network errors
- Use context-aware select/time.After in polling loop for responsive cancellation
- Add dedicated CodeMissingCodeZipArtifact error code
- Fix entry point auto-detection to use srcDir instead of cwd
- Replace hardcoded multipart boundary with mime/multipart.Writer
- Add unit tests for zipDeployRequest multipart format and headers

* fix(agents): apply agent_endpoint/agent_card via PatchAgent for code deploy and set metadata Content-Type

- Add PatchAgent call after code deploy create/update to apply agent_endpoint and agent_card fields (matching container deploy behavior)
- Use CreatePart with explicit Content-Type: application/json for the metadata multipart part instead of CreateFormField
- Update unit test to verify metadata part Content-Type header

* fix(agents): resolve CI lint and cspell errors

- Add //nolint:gosec to os.ReadFile in init_from_code.go
- Handle req.Body.Close() return value in test transport
- Suppress Close/Remove errors in deferred cleanup with _ =
- Add 'mypy' to cspell.yaml words list

* style: use map[string]any instead of map[string]interface{}

* feat(agents): add code deploy support to template init flow

Add deploy mode prompt (code vs container) to the template init flow,
allowing users to choose code deploy when initializing from a template.
Skip ACR configuration when code deploy is selected. Auto-derive
startup command from entry_point for code deploy instead of prompting.

* fix(agents): improve deploy mode prompt and clean agent.yaml on mode switch

- Default to Container (Docker) for backward compatibility
- Use clearer labels: 'Container (Docker)' / 'Code deploy (ZIP upload)'
- Remove code_configuration from agent.yaml when switching to container mode

* fix(agents): guard configureAcrConnection with skipACR check

When skipACR is true (code deploy mode), skip the configureAcrConnection
call entirely to prevent prompting users for ACR configuration.

* fix(agents): resolve project path when init runs from subdirectory

When running 'azd ai agent init' from a subdirectory with an existing
agent.manifest.yaml, the addToProject function received targetDir='.'
which wrote 'project: .' into azure.yaml. Since azure.yaml resolves
paths relative to the project root, this caused the service to point
to the wrong directory.

Fix: resolve the actual relative path from project root to cwd when
targetDir is '.', so azure.yaml gets the correct project path (e.g.
'src/hello-world-python-invocations' instead of '.').

* fix(agents): address PR #8146 review feedback (13 items)

- T1: Hide code deploy for non-Python projects (isPythonProject check)
- T2: Add TODO for region validation in code deploy
- T3: Reorder runtime list to 3.11, 3.12, 3.13
- T4: Update entry point prompt wording
- T6: Add descriptions to bundled/remote_build choices
- J1: Consolidate promptCodeConfig into single shared function
- J3: Use errors.AsType[*azcore.ResponseError] per Go 1.26
- J4: Extract shared deriveStartupCommand helper
- V1: Rename to 'Container Image (Docker)' / 'Source Code (ZIP upload)'
- V2: Unify HostedAgentDefinition with custom JSON marshal/unmarshal
- V4: Fix error message to reference 'azd package'
- V5: Extract prepareDeploy/finalizeDeploy shared helpers
- C1+C3: Verify ZIP exclusions (.azure, .env) and temp file cleanup

* fix(agents): add TODO for streaming ZIP in zipDeployRequest (C2)

* fix: remove unused isContainerAgent method and accidental files

* chore: remove accidentally committed files

* fix(agents): restrict code deploy to supported regions and fix depRes default

Add region validation for code deploy at both init-time (filter project
list) and deploy-time (fail early with clear error). Supported regions:
westus2, canadacentral, northcentralus.

Unify dependency_resolution fallback default to 'remote_build' to match
--no-prompt behavior.

* fix(agents): deduplicate codeDeployRegions and handle empty AZURE_LOCATION

Move CodeDeployRegions to project.config.go as a shared exported var,
referenced by both init filtering and deploy validation. Add explicit
check for empty AZURE_LOCATION with actionable error message.

* fix(agents): improve deploy failure diagnostics and rename resource prompt

- Include service error code/message and x-request-id in remote build failure errors
- Rename 'container resource allocation' prompt to 'Select resources (CPU and Memory)'

---------

Co-authored-by: Jian Wu <wujia@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants