azure-dev icon indicating copy to clipboard operation
azure-dev copied to clipboard

[Issue] Can not use "provision" or "deploy --from-package" without project source code available

Open sebastianmattar opened this issue 2 years ago • 8 comments

  • [x] Make sure you've installed the latest version using instructions in the wiki

Output from azd version azd version 0.8.0-beta.1 (commit 08209da7c22d28c6a123ef4e88d433132066b800)

Describe the bug My company requires separation of build, provision and deployment steps in our build pipeline. azd seems to support this scenario in the deployment step by using azd deploy --with-package. Currently, running azd provision without the source code available fails with an error. This does not make sense to me, as there should be not dependency on the source code to provision the bicep templates.

azd provision -e xxxx-test  --no-prompt --debug
2023/04/17 15:25:30 main.go:166: using cached latest version: 0.8.0-beta.1 (expires on: 2023-04-18T13:13:40Z)
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-config-list-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-config-get-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-config-set-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-config-unset-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-config-reset-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-config-list-alpha-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-env-set-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-env-set-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-env-select-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-env-new-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-env-new-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-env-list-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-env-refresh-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-env-refresh-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-env-get-values-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-env-get-values-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-infra-create-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-infra-create-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-infra-delete-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-infra-delete-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-pipeline-config-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-pipeline-config-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-telemetry-upload-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-template-list-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-template-show-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-auth-token-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-auth-token-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-auth-login-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-auth-login-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-auth-logout-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-version-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-version-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-show-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-show-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-login-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-login-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-logout-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-init-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-init-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-restore-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-restore-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-build-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-build-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-provision-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-provision-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-package-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-package-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-deploy-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-deploy-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-up-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-up-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-monitor-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-monitor-action'
2023/04/17 15:25:30 cobra_builder.go:172: registering flags for action 'azd-down-action'
2023/04/17 15:25:30 cobra_builder.go:192: registering resolver for action 'azd-down-action'
2023/04/17 15:25:30 project.go:85: Reading project from file 'C:\Projekte\temp\drop\drop\azure.yaml'
2023/04/17 15:25:30 cobra_builder.go:133: Resolved action 'azd-provision-action'
2023/04/17 15:25:30 middleware.go:124: running middleware 'debug'
2023/04/17 15:25:30 middleware.go:124: running middleware 'telemetry'
2023/04/17 15:25:30 middleware.go:124: running middleware 'hooks'
2023/04/17 15:25:30 hooks.go:134: service 'web' does not require any command hooks.
2023/04/17 15:25:30 hooks.go:134: service 'func' does not require any command hooks.
2023/04/17 15:25:30 hooks.go:80: azd project is not available or does not contain any command hooks, skipping command hook registrations.

Provisioning Azure resources (azd provision)
Provisioning Azure resources can take some time


ERROR: initializing service 'web', CreateFile C:\Projekte\temp\drop\drop\server\xxxx.Server: The system cannot find the path specified.

My azure.yaml:

# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json

name: xxxx
services:
    web: # maps to tag 'azd-service-name': 'web'
        project: server/xxxx.Server
        language: csharp
        host: appservice
    func: # maps to tag 'azd-service-name': 'func'
        project: server/xxxx.Functions
        language: csharp
        host: function
infra:
    provider: "bicep"
    path: "infra"
    module: "main"
pipeline:
    provider: azdo

To Reproduce Try to provision/deploy your project without the source code being available.

Expected behavior I would to be able to deploy/provision my project without the source code, just binaries, config file and templates.

Environment Information on your environment: * Language name and version. .NET 7, C# * IDE and version : [e.g. Visual Studio 16.3], VSCode latest

Additional context Add any other context about the problem here.

sebastianmattar avatar Apr 17 '23 13:04 sebastianmattar

I just tried to use azd deploy web --from-package web --debug without the source being available, getting the same error message:

ERROR: initializing service 'web', CreateFile C:\Projekte\temp\drop\drop\server\xxxx.Server: The system cannot find the path specified.

sebastianmattar avatar Apr 17 '23 13:04 sebastianmattar

@sebastianmattar thanks for filing an issue. Please share the repo, if handy.

Azd today does not support projects with no source/project files. Adding it to backlog as a feature request.

@savannahostrowski @ellismg

rajeshkamal5050 avatar Apr 17 '23 15:04 rajeshkamal5050

Alright! Having this feature would be of great benefit to us because we could retire our custom scripts. Sorry, I have no repro I can share...

sebastianmattar avatar Apr 18 '23 11:04 sebastianmattar

@sebastianmattar Great that you're able to find azd close to working for your scenario. Logically, I see no reason why azd provision and azd deploy --from-package <path> wouldn't work if you didn't have the full source code available, and just azure.yaml and the environment being present.

Older versions of azd may have actually worked for your situation, but recent refactorings may have changed the behavior here.

weikanglim avatar May 05 '23 00:05 weikanglim

Yes, it seems azd fails when it tries to call dotnet user-secrets ... which was introduced some time ago.

sebastianmattar avatar May 05 '23 08:05 sebastianmattar

Any update on this?

TWolversonReply avatar Feb 01 '24 20:02 TWolversonReply

In my scenario, I tried creating an empty file matching the path specified in the service definition in case I could unblock provisioning if all it expects is for the specified file to be there, and I got the same result that @sebastianmattar had - a stack trace beginning:

ERROR: initializing service 'api', failed to initialize secrets at project '/home/vsts/work/1/s/src/': exit code: 1, stdout: System.Xml.XmlException: Root element is missing

I agree that this operation has no reason to care about source code at all, and certainly not mess with user-secrets.

TWolversonReply avatar Feb 02 '24 09:02 TWolversonReply

Any update?

TWolversonReply avatar May 21 '24 08:05 TWolversonReply

I would also be interested in any update

GABRIELNGBTUC avatar Mar 04 '25 10:03 GABRIELNGBTUC

It should also be pointed that azd env refresh, which is necessary in an environment where the build, provision and deployment are seperate, is affected by this issue.

GABRIELNGBTUC avatar Mar 11 '25 09:03 GABRIELNGBTUC

In my scenario, I tried creating an empty file matching the path specified in the service definition in case I could unblock provisioning if all it expects is for the specified file to be there, and I got the same result that @sebastianmattar had

works okay if you create a non-empty file like echo "<Project />" > ./src/Service.csproj or wherever path is referenced and bundle that along with your /infra and yaml. I have a pipeline with multiple environment stages where I provision and deploy from package using a build artifact. Feels like I shouldn't need to.

lroos avatar Jul 22 '25 11:07 lroos