upload
napt.upload.manager
Upload orchestrator for NAPT Intune deployment.
Coordinates the full upload pipeline: loading recipe config, inferring the package path, authenticating, parsing the .intunewin file, building app metadata, and executing the Graph API upload flow.
upload_package
Upload a packaged app to Microsoft Intune via the Graph API.
Loads the recipe config, infers the .intunewin package path, authenticates using the available Azure credential, parses encryption metadata from the package, and executes the full Graph API upload flow.
When intune.build_types is "both" (the default), two Intune app entries are created: an install entry (detection script only) and an update entry (detection + requirements scripts). Each entry is created, uploaded, and committed in sequence before moving to the next.
The package directory is inferred as packages/{app.id}/{version}/. Run 'napt package' before calling this function.
Authentication needs no configuration file:
- Developers: run 'napt auth login' once
- CI/CD: set AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET, or use OIDC federation
Before any Graph call, the package's installer hash (from the build manifest) is verified against the pending release recorded in the app's deployment state, so what was recorded at discovery is byte-for-byte what ships. A hash mismatch aborts the upload. When no pending release is recorded, the upload proceeds with a warning — or fails when deployment.require_pending is enabled. On success, the deployment state records the published version, hash, and Intune app IDs, and a matching pending slot is cleared.
Re-running an upload is safe: existing NAPT-stamped apps matching this publish instance (recipe id, entry type, installer hash) are adopted — or their interrupted content upload resumed — instead of duplicated. Adoption keeps the app as it is; it does not re-send metadata or content. Pass force=True to update matched apps' metadata and upload a fresh content version (e.g., after changing PSADT commands or detection settings without a new installer release).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe_path
|
Path
|
Path to the recipe YAML file. |
required |
force
|
bool
|
When True, matched stamped apps are re-uploaded (metadata and content) instead of adopted as-is. Never creates duplicates. |
False
|
Returns:
| Type | Description |
|---|---|
UploadResult
|
Upload result including the Intune app ID(s), app name, version, and package path. intune_app_id is None when build_types is "update_only"; intune_update_app_id is None when build_types is "app_only". |
Raises:
| Type | Description |
|---|---|
ConfigError
|
If the package directory is not found, or detection/ requirements scripts are absent from the package directory. Run 'napt package' to create or recreate the package. |
AuthError
|
If all Azure credential methods fail. |
NetworkError
|
If Graph API or Azure Blob Storage calls fail. |
PackagingError
|
If the .intunewin file is malformed, the package's installer hash does not match the pending release in deployment state, or no pending release is recorded while deployment.require_pending is enabled. |
StateError
|
On a corrupted deployment state file. |
Example
Upload and print the resulting Intune app IDs:
Source code in napt/upload/manager.py
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 | |
napt.upload.intunewin
Parses .intunewin package files for NAPT upload operations.
A .intunewin file is a ZIP archive created by IntuneWinAppUtil with the following structure:
IntuneWinPackage/
Contents/
IntunePackage.intunewin <- encrypted payload
Metadata/
Detection.xml <- encryption metadata
This module extracts the encryption metadata from Detection.xml and provides utilities for extracting the encrypted payload for upload to Azure Blob Storage.
IntunewinMetadata
dataclass
Encryption metadata extracted from a .intunewin package.
All fields are sourced from Detection.xml inside the .intunewin ZIP archive. This metadata is required by the Graph API file commit endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
encrypted_file_name |
str
|
Filename of the encrypted payload inside the Contents/ directory (always "IntunePackage.intunewin"). |
unencrypted_content_size |
int
|
Original size in bytes before encryption. |
file_digest |
str
|
Base64-encoded SHA-256 hash of the encrypted payload. |
file_digest_algorithm |
str
|
Hash algorithm used (always "SHA256"). |
encryption_key |
str
|
Base64-encoded AES-256 encryption key. |
mac_key |
str
|
Base64-encoded HMAC key for MAC verification. |
init_vector |
str
|
Base64-encoded AES initialization vector. |
mac |
str
|
Base64-encoded MAC value for integrity verification. |
profile_identifier |
str
|
Encryption profile version (always "ProfileVersion1"). |
encrypted_file_size |
int
|
Byte size of the encrypted payload file. |
Source code in napt/upload/intunewin.py
parse_intunewin
Parse a .intunewin package and extract encryption metadata.
Reads IntuneWinPackage/Metadata/Detection.xml from inside the .intunewin ZIP and returns all encryption fields required for the Graph API upload flow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intunewin_path
|
Path
|
Path to the .intunewin file to parse. |
required |
Returns:
| Type | Description |
|---|---|
IntunewinMetadata
|
Parsed encryption metadata from Detection.xml. |
Raises:
| Type | Description |
|---|---|
PackagingError
|
If the file is not a valid ZIP, Detection.xml is missing, or required XML fields are absent or malformed. |
Example
Parse an existing package:
Source code in napt/upload/intunewin.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
extract_encrypted_payload
Extract the encrypted payload from a .intunewin package.
Extracts IntuneWinPackage/Contents/IntunePackage.intunewin to the destination directory for upload to Azure Blob Storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intunewin_path
|
Path
|
Path to the .intunewin file. |
required |
dest_dir
|
Path
|
Directory to extract the payload into. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the extracted encrypted payload file. |
Raises:
| Type | Description |
|---|---|
PackagingError
|
If the file is not a valid ZIP or the payload is missing. |